Use domain specific assertions for shard failures across tests

This commit is contained in:
Simon Willnauer 2013-08-05 17:50:24 +02:00
parent df747836d8
commit 1983a3676a
13 changed files with 210 additions and 219 deletions

View File

@ -19,21 +19,7 @@
package org.elasticsearch.test.integration.document;
import static org.elasticsearch.client.Requests.clearIndicesCacheRequest;
import static org.elasticsearch.client.Requests.clusterHealthRequest;
import static org.elasticsearch.client.Requests.countRequest;
import static org.elasticsearch.client.Requests.getRequest;
import static org.elasticsearch.client.Requests.indexRequest;
import static org.elasticsearch.client.Requests.refreshRequest;
import static org.elasticsearch.index.query.QueryBuilders.termQuery;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.nullValue;
import java.io.IOException;
import java.util.Map;
import com.google.common.base.Charsets;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
import org.elasticsearch.action.admin.indices.cache.clear.ClearIndicesCacheResponse;
@ -54,7 +40,14 @@ import org.elasticsearch.test.integration.AbstractSharedClusterTest;
import org.junit.BeforeClass;
import org.junit.Test;
import com.google.common.base.Charsets;
import java.io.IOException;
import java.util.Map;
import static org.elasticsearch.client.Requests.*;
import static org.elasticsearch.index.query.QueryBuilders.termQuery;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.nullValue;
/**
*
@ -186,7 +179,7 @@ public class DocumentActionsTests extends AbstractSharedClusterTest {
for (int i = 0; i < 5; i++) {
// test successful
CountResponse countResponse = client().prepareCount("test").setQuery(termQuery("_type", "type1")).setOperationThreading(BroadcastOperationThreading.NO_THREADS).execute().actionGet();
assertThat("Failures " + countResponse.getShardFailures(), countResponse.getShardFailures()==null?0:countResponse.getShardFailures().length, equalTo(0));
assertNoFailures(countResponse);
assertThat(countResponse.getCount(), equalTo(2l));
assertThat(countResponse.getSuccessfulShards(), equalTo(5));
assertThat(countResponse.getFailedShards(), equalTo(0));

View File

@ -42,13 +42,11 @@ import org.elasticsearch.test.integration.AbstractSharedClusterTest;
import org.junit.Assert;
import org.junit.Test;
import java.util.Arrays;
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.index.query.FilterBuilders.*;
import static org.elasticsearch.index.query.QueryBuilders.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
import static org.hamcrest.Matchers.*;
public class SimpleNestedTests extends AbstractSharedClusterTest {
@ -103,11 +101,11 @@ public class SimpleNestedTests extends AbstractSharedClusterTest {
// now, do a nested query
searchResponse = run(client().prepareSearch("test").setQuery(nestedQuery("nested1", termQuery("nested1.n_field1", "n_value1_1"))));
assertThat(Arrays.toString(searchResponse.getShardFailures()), searchResponse.getFailedShards(), equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
searchResponse = run(client().prepareSearch("test").setQuery(nestedQuery("nested1", termQuery("nested1.n_field1", "n_value1_1"))).setSearchType(SearchType.DFS_QUERY_THEN_FETCH));
assertThat(Arrays.toString(searchResponse.getShardFailures()), searchResponse.getFailedShards(), equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
// add another doc, one that would match if it was not nested...
@ -133,19 +131,19 @@ public class SimpleNestedTests extends AbstractSharedClusterTest {
searchResponse = client().prepareSearch("test").setQuery(nestedQuery("nested1",
boolQuery().must(termQuery("nested1.n_field1", "n_value1_1")).must(termQuery("nested1.n_field2", "n_value2_1")))).execute().actionGet();
assertThat(Arrays.toString(searchResponse.getShardFailures()), searchResponse.getFailedShards(), equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
// filter
searchResponse = client().prepareSearch("test").setQuery(filteredQuery(matchAllQuery(), nestedFilter("nested1",
boolQuery().must(termQuery("nested1.n_field1", "n_value1_1")).must(termQuery("nested1.n_field2", "n_value2_1"))))).execute().actionGet();
assertThat(Arrays.toString(searchResponse.getShardFailures()), searchResponse.getFailedShards(), equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
// check with type prefix
searchResponse = client().prepareSearch("test").setQuery(nestedQuery("type1.nested1",
boolQuery().must(termQuery("nested1.n_field1", "n_value1_1")).must(termQuery("nested1.n_field2", "n_value2_1")))).execute().actionGet();
assertThat(Arrays.toString(searchResponse.getShardFailures()), searchResponse.getFailedShards(), equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
// check delete, so all is gone...
@ -158,7 +156,7 @@ public class SimpleNestedTests extends AbstractSharedClusterTest {
assertThat(statusResponse.getIndex("test").getDocs().getNumDocs(), equalTo(3l));
searchResponse = client().prepareSearch("test").setQuery(nestedQuery("nested1", termQuery("nested1.n_field1", "n_value1_1"))).execute().actionGet();
assertThat(Arrays.toString(searchResponse.getShardFailures()), searchResponse.getFailedShards(), equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
}
@ -305,42 +303,42 @@ public class SimpleNestedTests extends AbstractSharedClusterTest {
// do some multi nested queries
SearchResponse searchResponse = client().prepareSearch("test").setQuery(nestedQuery("nested1",
termQuery("nested1.field1", "1"))).execute().actionGet();
assertThat(Arrays.toString(searchResponse.getShardFailures()), searchResponse.getFailedShards(), equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
searchResponse = client().prepareSearch("test").setQuery(nestedQuery("nested1.nested2",
termQuery("nested1.nested2.field2", "2"))).execute().actionGet();
assertThat(Arrays.toString(searchResponse.getShardFailures()), searchResponse.getFailedShards(), equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
searchResponse = client().prepareSearch("test").setQuery(nestedQuery("nested1",
boolQuery().must(termQuery("nested1.field1", "1")).must(nestedQuery("nested1.nested2", termQuery("nested1.nested2.field2", "2"))))).execute().actionGet();
assertThat(Arrays.toString(searchResponse.getShardFailures()), searchResponse.getFailedShards(), equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
searchResponse = client().prepareSearch("test").setQuery(nestedQuery("nested1",
boolQuery().must(termQuery("nested1.field1", "1")).must(nestedQuery("nested1.nested2", termQuery("nested1.nested2.field2", "3"))))).execute().actionGet();
assertThat(Arrays.toString(searchResponse.getShardFailures()), searchResponse.getFailedShards(), equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
searchResponse = client().prepareSearch("test").setQuery(nestedQuery("nested1",
boolQuery().must(termQuery("nested1.field1", "1")).must(nestedQuery("nested1.nested2", termQuery("nested1.nested2.field2", "4"))))).execute().actionGet();
assertThat(Arrays.toString(searchResponse.getShardFailures()), searchResponse.getFailedShards(), equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(0l));
searchResponse = client().prepareSearch("test").setQuery(nestedQuery("nested1",
boolQuery().must(termQuery("nested1.field1", "1")).must(nestedQuery("nested1.nested2", termQuery("nested1.nested2.field2", "5"))))).execute().actionGet();
assertThat(Arrays.toString(searchResponse.getShardFailures()), searchResponse.getFailedShards(), equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(0l));
searchResponse = client().prepareSearch("test").setQuery(nestedQuery("nested1",
boolQuery().must(termQuery("nested1.field1", "4")).must(nestedQuery("nested1.nested2", termQuery("nested1.nested2.field2", "5"))))).execute().actionGet();
assertThat(Arrays.toString(searchResponse.getShardFailures()), searchResponse.getFailedShards(), equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
searchResponse = client().prepareSearch("test").setQuery(nestedQuery("nested1",
boolQuery().must(termQuery("nested1.field1", "4")).must(nestedQuery("nested1.nested2", termQuery("nested1.nested2.field2", "2"))))).execute().actionGet();
assertThat(Arrays.toString(searchResponse.getShardFailures()), searchResponse.getFailedShards(), equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(0l));
}
@ -396,7 +394,7 @@ public class SimpleNestedTests extends AbstractSharedClusterTest {
.facetFilter(boolFilter().must(termFilter("field2_1", "blue"))))
.execute().actionGet();
assertThat(Arrays.toString(searchResponse.getShardFailures()), searchResponse.getFailedShards(), equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(2l));
TermsStatsFacet termsStatsFacet = searchResponse.getFacets().facet("facet1");
@ -443,7 +441,7 @@ public class SimpleNestedTests extends AbstractSharedClusterTest {
)
.execute().actionGet();
assertThat(Arrays.toString(searchResponse.getShardFailures()), searchResponse.getFailedShards(), equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(2l));
termsStatsFacet = searchResponse.getFacets().facet("facet1");
@ -466,7 +464,7 @@ public class SimpleNestedTests extends AbstractSharedClusterTest {
)
.execute().actionGet();
assertThat(Arrays.toString(searchResponse.getShardFailures()), searchResponse.getFailedShards(), equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(2l));
FilterFacet filterFacet = searchResponse.getFacets().facet("facet1");
@ -570,7 +568,7 @@ public class SimpleNestedTests extends AbstractSharedClusterTest {
.setQuery(nestedQuery("nested1", termQuery("nested1.n_field1", "n_value1")).scoreMode("total"))
.setExplain(true)
.execute().actionGet();
assertThat(Arrays.toString(searchResponse.getShardFailures()), searchResponse.getFailedShards(), equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
Explanation explanation = searchResponse.getHits().hits()[0].explanation();
assertThat(explanation.getValue(), equalTo(2f));

View File

@ -49,9 +49,11 @@ import java.util.concurrent.atomic.AtomicReference;
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
import static org.elasticsearch.index.query.QueryBuilders.boolQuery;
import static org.elasticsearch.index.query.QueryBuilders.termQuery;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
import static org.elasticsearch.test.integration.percolator.SimplePercolatorTests.convertFromTextArray;
import static org.hamcrest.Matchers.*;
/**
*
*/
@ -277,7 +279,7 @@ public class ConcurrentPercolatorTests extends AbstractNodesTests {
atLeastExpected = type1.get();
response = client().preparePercolate().setIndices("index").setDocumentType("type")
.setSource(onlyField1Doc).execute().actionGet();
assertThat(response.getShardFailures(), emptyArray());
assertNoFailures(response);
assertThat(response.getSuccessfulShards(), equalTo(response.getTotalShards()));
assertThat(response.getMatches().length, greaterThanOrEqualTo(atLeastExpected));
break;
@ -285,7 +287,7 @@ public class ConcurrentPercolatorTests extends AbstractNodesTests {
atLeastExpected = type2.get();
response = client().preparePercolate().setIndices("index").setDocumentType("type")
.setSource(onlyField2Doc).execute().actionGet();
assertThat(response.getShardFailures(), emptyArray());
assertNoFailures(response);
assertThat(response.getSuccessfulShards(), equalTo(response.getTotalShards()));
assertThat(response.getMatches().length, greaterThanOrEqualTo(atLeastExpected));
break;
@ -293,7 +295,7 @@ public class ConcurrentPercolatorTests extends AbstractNodesTests {
atLeastExpected = type3.get();
response = client().preparePercolate().setIndices("index").setDocumentType("type")
.setSource(field1AndField2Doc).execute().actionGet();
assertThat(response.getShardFailures(), emptyArray());
assertNoFailures(response);
assertThat(response.getSuccessfulShards(), equalTo(response.getTotalShards()));
assertThat(response.getMatches().length, greaterThanOrEqualTo(atLeastExpected));
break;

View File

@ -39,7 +39,6 @@ import org.elasticsearch.test.integration.AbstractSharedClusterTest;
import org.junit.Test;
import java.io.IOException;
import java.util.Arrays;
import java.util.Set;
import static org.elasticsearch.action.search.SearchType.*;
@ -50,7 +49,7 @@ import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
import static org.elasticsearch.index.query.QueryBuilders.termQuery;
import static org.elasticsearch.search.builder.SearchSourceBuilder.searchSource;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
import static org.hamcrest.Matchers.*;
/**
@ -104,7 +103,7 @@ public class TransportTwoNodesSearchTests extends AbstractSharedClusterTest {
.from(0).size(60).explain(true);
SearchResponse searchResponse = client().search(searchRequest("test").source(source).searchType(DFS_QUERY_THEN_FETCH).scroll(new Scroll(timeValueMinutes(10)))).actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(100l));
assertThat(searchResponse.getHits().hits().length, equalTo(60));
@ -135,7 +134,7 @@ public class TransportTwoNodesSearchTests extends AbstractSharedClusterTest {
.from(0).size(60).explain(true).sort("age", SortOrder.ASC);
SearchResponse searchResponse = client().search(searchRequest("test").source(source).searchType(DFS_QUERY_THEN_FETCH).scroll(new Scroll(timeValueMinutes(10)))).actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(100l));
assertThat(searchResponse.getHits().hits().length, equalTo(60));
for (int i = 0; i < 60; i++) {
@ -165,7 +164,7 @@ public class TransportTwoNodesSearchTests extends AbstractSharedClusterTest {
.from(0).size(60).explain(true);
SearchResponse searchResponse = client().search(searchRequest("test").source(source).searchType(QUERY_THEN_FETCH).scroll(new Scroll(timeValueMinutes(10)))).actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(100l));
assertThat(searchResponse.getHits().hits().length, equalTo(60));
for (int i = 0; i < 60; i++) {
@ -196,7 +195,7 @@ public class TransportTwoNodesSearchTests extends AbstractSharedClusterTest {
Set<String> collectedIds = Sets.newHashSet();
SearchResponse searchResponse = client().search(searchRequest("test").source(source.from(0).size(60)).searchType(QUERY_THEN_FETCH)).actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(100l));
assertThat(searchResponse.getHits().hits().length, equalTo(60));
for (int i = 0; i < 60; i++) {
@ -204,7 +203,7 @@ public class TransportTwoNodesSearchTests extends AbstractSharedClusterTest {
collectedIds.add(hit.id());
}
searchResponse = client().search(searchRequest("test").source(source.from(60).size(60)).searchType(QUERY_THEN_FETCH)).actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(100l));
assertThat(searchResponse.getHits().hits().length, equalTo(40));
for (int i = 0; i < 40; i++) {
@ -223,7 +222,7 @@ public class TransportTwoNodesSearchTests extends AbstractSharedClusterTest {
.from(0).size(60).explain(true).sort("age", SortOrder.ASC);
SearchResponse searchResponse = client().search(searchRequest("test").source(source).searchType(QUERY_THEN_FETCH).scroll(new Scroll(timeValueMinutes(10)))).actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(100l));
assertThat(searchResponse.getHits().hits().length, equalTo(60));
for (int i = 0; i < 60; i++) {
@ -257,7 +256,7 @@ public class TransportTwoNodesSearchTests extends AbstractSharedClusterTest {
}
SearchResponse searchResponse = client().search(searchRequest("test").source(source).searchType(QUERY_AND_FETCH).scroll(new Scroll(timeValueMinutes(10)))).actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(100l));
assertThat(searchResponse.getHits().hits().length, equalTo(60)); // 20 per shard
for (int i = 0; i < 60; i++) {
@ -297,7 +296,7 @@ public class TransportTwoNodesSearchTests extends AbstractSharedClusterTest {
SearchResponse searchResponse = client().search(searchRequest("test").source(source).searchType(DFS_QUERY_AND_FETCH).scroll(new Scroll(timeValueMinutes(10)))).actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(100l));
assertThat(searchResponse.getHits().hits().length, equalTo(60)); // 20 per shard
for (int i = 0; i < 60; i++) {
@ -333,7 +332,7 @@ public class TransportTwoNodesSearchTests extends AbstractSharedClusterTest {
.facet(FacetBuilders.queryFacet("test1", termQuery("name", "test1")));
SearchResponse searchResponse = client().search(searchRequest("test").source(sourceBuilder)).actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(100l));
assertThat(searchResponse.getFacets().facet(QueryFacet.class, "test1").getCount(), equalTo(1l));
@ -373,15 +372,15 @@ public class TransportTwoNodesSearchTests extends AbstractSharedClusterTest {
assertThat(response.getFailedShards(), equalTo(0));
response = client().search(searchRequest("test").searchType(QUERY_THEN_FETCH).source(source)).actionGet();
assertThat(Arrays.toString(response.getShardFailures()), response.getShardFailures().length, equalTo(0));
assertNoFailures(response);
assertThat(response.getHits().hits().length, equalTo(0));
response = client().search(searchRequest("test").searchType(DFS_QUERY_AND_FETCH).source(source)).actionGet();
assertThat(Arrays.toString(response.getShardFailures()), response.getShardFailures().length, equalTo(0));
assertNoFailures(response);
assertThat(response.getHits().hits().length, equalTo(0));
response = client().search(searchRequest("test").searchType(DFS_QUERY_THEN_FETCH).source(source)).actionGet();
assertThat(Arrays.toString(response.getShardFailures()), response.getShardFailures().length, equalTo(0));
assertNoFailures(response);
assertThat(response.getHits().hits().length, equalTo(0));
logger.info("Done Testing failed search");

View File

@ -43,6 +43,7 @@ import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.index.query.FilterBuilders.*;
import static org.elasticsearch.index.query.QueryBuilders.*;
import static org.elasticsearch.search.facet.FacetBuilders.termsFacet;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
import static org.hamcrest.Matchers.*;
/**
@ -85,7 +86,7 @@ public class SimpleChildQuerySearchTests extends AbstractSharedClusterTest {
)
)
.execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("p1"));
@ -99,7 +100,7 @@ public class SimpleChildQuerySearchTests extends AbstractSharedClusterTest {
)
)
).execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("c1"));
@ -113,7 +114,7 @@ public class SimpleChildQuerySearchTests extends AbstractSharedClusterTest {
)
)
).execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("gc1"));
@ -124,7 +125,7 @@ public class SimpleChildQuerySearchTests extends AbstractSharedClusterTest {
termQuery("p_field", "p_value1")
)
).execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("c1"));
@ -135,7 +136,7 @@ public class SimpleChildQuerySearchTests extends AbstractSharedClusterTest {
termQuery("c_field", "c_value1")
)
).execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("gc1"));
}
@ -195,7 +196,7 @@ public class SimpleChildQuerySearchTests extends AbstractSharedClusterTest {
.setQuery(idsQuery("child").ids("c1"))
.addFields("_parent")
.execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getFailedShards(), equalTo(0));
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("c1"));
@ -206,7 +207,7 @@ public class SimpleChildQuerySearchTests extends AbstractSharedClusterTest {
.setQuery(termQuery("child._parent", "p1"))
.addFields("_parent")
.execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getFailedShards(), equalTo(0));
assertThat(searchResponse.getHits().totalHits(), equalTo(2l));
assertThat(searchResponse.getHits().getAt(0).id(), anyOf(equalTo("c1"), equalTo("c2")));
@ -218,7 +219,7 @@ public class SimpleChildQuerySearchTests extends AbstractSharedClusterTest {
.setQuery(termQuery("_parent", "p1"))
.addFields("_parent")
.execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getFailedShards(), equalTo(0));
assertThat(searchResponse.getHits().totalHits(), equalTo(2l));
assertThat(searchResponse.getHits().getAt(0).id(), anyOf(equalTo("c1"), equalTo("c2")));
@ -230,7 +231,7 @@ public class SimpleChildQuerySearchTests extends AbstractSharedClusterTest {
.setQuery(queryString("_parent:p1"))
.addFields("_parent")
.execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getFailedShards(), equalTo(0));
assertThat(searchResponse.getHits().totalHits(), equalTo(2l));
assertThat(searchResponse.getHits().getAt(0).id(), anyOf(equalTo("c1"), equalTo("c2")));
@ -244,7 +245,7 @@ public class SimpleChildQuerySearchTests extends AbstractSharedClusterTest {
searchResponse = client().prepareSearch("test")
.setQuery(topChildrenQuery("child", termQuery("c_field", "yellow")))
.execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getFailedShards(), equalTo(0));
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("p1"));
@ -261,7 +262,7 @@ public class SimpleChildQuerySearchTests extends AbstractSharedClusterTest {
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("p2"));
searchResponse = client().prepareSearch("test").setQuery(topChildrenQuery("child", termQuery("c_field", "red"))).execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getFailedShards(), equalTo(0));
assertThat(searchResponse.getHits().totalHits(), equalTo(2l));
assertThat(searchResponse.getHits().getAt(0).id(), anyOf(equalTo("p2"), equalTo("p1")));
@ -281,13 +282,13 @@ public class SimpleChildQuerySearchTests extends AbstractSharedClusterTest {
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("p1"));
searchResponse = client().prepareSearch("test").setQuery(hasChildQuery("child", termQuery("c_field", "blue"))).execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getFailedShards(), equalTo(0));
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("p2"));
searchResponse = client().prepareSearch("test").setQuery(hasChildQuery("child", termQuery("c_field", "red"))).execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getFailedShards(), equalTo(0));
assertThat(searchResponse.getHits().totalHits(), equalTo(2l));
assertThat(searchResponse.getHits().getAt(0).id(), anyOf(equalTo("p2"), equalTo("p1")));
@ -296,7 +297,7 @@ public class SimpleChildQuerySearchTests extends AbstractSharedClusterTest {
// HAS CHILD FILTER
searchResponse = client().prepareSearch("test").setQuery(constantScoreQuery(hasChildFilter("child", termQuery("c_field", "yellow")))).execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getFailedShards(), equalTo(0));
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("p1"));
@ -313,7 +314,7 @@ public class SimpleChildQuerySearchTests extends AbstractSharedClusterTest {
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("p2"));
searchResponse = client().prepareSearch("test").setQuery(constantScoreQuery(hasChildFilter("child", termQuery("c_field", "red")))).execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getFailedShards(), equalTo(0));
assertThat(searchResponse.getHits().totalHits(), equalTo(2l));
assertThat(searchResponse.getHits().getAt(0).id(), anyOf(equalTo("p2"), equalTo("p1")));
@ -321,14 +322,14 @@ public class SimpleChildQuerySearchTests extends AbstractSharedClusterTest {
// HAS PARENT FILTER
searchResponse = client().prepareSearch("test").setQuery(constantScoreQuery(hasParentFilter("parent", termQuery("p_field", "p_value2")))).execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getFailedShards(), equalTo(0));
assertThat(searchResponse.getHits().totalHits(), equalTo(2l));
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("c3"));
assertThat(searchResponse.getHits().getAt(1).id(), equalTo("c4"));
searchResponse = client().prepareSearch("test").setQuery(constantScoreQuery(hasParentFilter("parent", termQuery("p_field", "p_value1")))).execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getFailedShards(), equalTo(0));
assertThat(searchResponse.getHits().totalHits(), equalTo(2l));
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("c1"));
@ -336,14 +337,14 @@ public class SimpleChildQuerySearchTests extends AbstractSharedClusterTest {
// HAS PARENT QUERY
searchResponse = client().prepareSearch("test").setQuery(hasParentQuery("parent", termQuery("p_field", "p_value2"))).execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getFailedShards(), equalTo(0));
assertThat(searchResponse.getHits().totalHits(), equalTo(2l));
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("c3"));
assertThat(searchResponse.getHits().getAt(1).id(), equalTo("c4"));
searchResponse = client().prepareSearch("test").setQuery(hasParentQuery("parent", termQuery("p_field", "p_value1"))).execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getFailedShards(), equalTo(0));
assertThat(searchResponse.getHits().totalHits(), equalTo(2l));
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("c1"));
@ -382,13 +383,13 @@ public class SimpleChildQuerySearchTests extends AbstractSharedClusterTest {
for (int i = 0; i < 10; i++) {
SearchResponse searchResponse = client().prepareSearch("test").setQuery(constantScoreQuery(queryFilter(topChildrenQuery("child", matchAllQuery())).cache(true)))
.execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
searchResponse = client().prepareSearch("test").setQuery(constantScoreQuery(queryFilter(hasChildQuery("child", matchAllQuery()).scoreType("max")).cache(true)))
.execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
searchResponse = client().prepareSearch("test").setQuery(constantScoreQuery(queryFilter(hasParentQuery("parent", matchAllQuery()).scoreType("score")).cache(true)))
.execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
}
}
@ -442,7 +443,7 @@ public class SimpleChildQuerySearchTests extends AbstractSharedClusterTest {
.setSize(numChildDocsPerParent)
.execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getFailedShards(), equalTo(0));
Set<String> childIds = parentToChildrenEntry.getValue();
assertThat(searchResponse.getHits().totalHits(), equalTo((long) childIds.size()));
@ -488,7 +489,7 @@ public class SimpleChildQuerySearchTests extends AbstractSharedClusterTest {
// TOP CHILDREN QUERY
SearchResponse searchResponse = client().prepareSearch("test").setQuery(topChildrenQuery("child", termQuery("c_field", "yellow"))).execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getFailedShards(), equalTo(0));
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("p1"));
@ -505,7 +506,7 @@ public class SimpleChildQuerySearchTests extends AbstractSharedClusterTest {
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("p2"));
searchResponse = client().prepareSearch("test").setQuery(topChildrenQuery("child", termQuery("c_field", "red"))).execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getFailedShards(), equalTo(0));
assertThat(searchResponse.getHits().totalHits(), equalTo(2l));
assertThat(searchResponse.getHits().getAt(0).id(), anyOf(equalTo("p2"), equalTo("p1")));
@ -514,19 +515,19 @@ public class SimpleChildQuerySearchTests extends AbstractSharedClusterTest {
// HAS CHILD QUERY
searchResponse = client().prepareSearch("test").setQuery(hasChildQuery("child", termQuery("c_field", "yellow"))).execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getFailedShards(), equalTo(0));
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("p1"));
searchResponse = client().prepareSearch("test").setQuery(hasChildQuery("child", termQuery("c_field", "blue"))).execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getFailedShards(), equalTo(0));
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("p2"));
searchResponse = client().prepareSearch("test").setQuery(hasChildQuery("child", termQuery("c_field", "red"))).execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getFailedShards(), equalTo(0));
assertThat(searchResponse.getHits().totalHits(), equalTo(2l));
assertThat(searchResponse.getHits().getAt(0).id(), anyOf(equalTo("p2"), equalTo("p1")));
@ -535,19 +536,19 @@ public class SimpleChildQuerySearchTests extends AbstractSharedClusterTest {
// HAS CHILD FILTER
searchResponse = client().prepareSearch("test").setQuery(constantScoreQuery(hasChildFilter("child", termQuery("c_field", "yellow")))).execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getFailedShards(), equalTo(0));
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("p1"));
searchResponse = client().prepareSearch("test").setQuery(constantScoreQuery(hasChildFilter("child", termQuery("c_field", "blue")))).execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getFailedShards(), equalTo(0));
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("p2"));
searchResponse = client().prepareSearch("test").setQuery(constantScoreQuery(hasChildFilter("child", termQuery("c_field", "red")))).execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getFailedShards(), equalTo(0));
assertThat(searchResponse.getHits().totalHits(), equalTo(2l));
assertThat(searchResponse.getHits().getAt(0).id(), anyOf(equalTo("p2"), equalTo("p1")));
@ -587,7 +588,7 @@ public class SimpleChildQuerySearchTests extends AbstractSharedClusterTest {
// TOP CHILDREN QUERY
SearchResponse searchResponse = client().prepareSearch("test").setQuery(topChildrenQuery("child", termQuery("c_field", "yellow"))).execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getFailedShards(), equalTo(0));
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("p1"));
@ -604,7 +605,7 @@ public class SimpleChildQuerySearchTests extends AbstractSharedClusterTest {
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("p2"));
searchResponse = client().prepareSearch("test").setQuery(topChildrenQuery("child", termQuery("c_field", "red"))).execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getFailedShards(), equalTo(0));
assertThat(searchResponse.getHits().totalHits(), equalTo(2l));
assertThat(searchResponse.getHits().getAt(0).id(), anyOf(equalTo("p2"), equalTo("p1")));
@ -613,19 +614,19 @@ public class SimpleChildQuerySearchTests extends AbstractSharedClusterTest {
// HAS CHILD QUERY
searchResponse = client().prepareSearch("test").setQuery(hasChildQuery("child", termQuery("c_field", "yellow"))).execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getFailedShards(), equalTo(0));
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("p1"));
searchResponse = client().prepareSearch("test").setQuery(hasChildQuery("child", termQuery("c_field", "blue"))).execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getFailedShards(), equalTo(0));
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("p2"));
searchResponse = client().prepareSearch("test").setQuery(hasChildQuery("child", termQuery("c_field", "red"))).execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getFailedShards(), equalTo(0));
assertThat(searchResponse.getHits().totalHits(), equalTo(2l));
assertThat(searchResponse.getHits().getAt(0).id(), anyOf(equalTo("p2"), equalTo("p1")));
@ -634,19 +635,19 @@ public class SimpleChildQuerySearchTests extends AbstractSharedClusterTest {
// HAS CHILD FILTER
searchResponse = client().prepareSearch("test").setQuery(constantScoreQuery(hasChildFilter("child", termQuery("c_field", "yellow")))).execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getFailedShards(), equalTo(0));
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("p1"));
searchResponse = client().prepareSearch("test").setQuery(constantScoreQuery(hasChildFilter("child", termQuery("c_field", "blue")))).execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getFailedShards(), equalTo(0));
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("p2"));
searchResponse = client().prepareSearch("test").setQuery(constantScoreQuery(hasChildFilter("child", termQuery("c_field", "red")))).execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getFailedShards(), equalTo(0));
assertThat(searchResponse.getHits().totalHits(), equalTo(2l));
assertThat(searchResponse.getHits().getAt(0).id(), anyOf(equalTo("p2"), equalTo("p1")));
@ -689,7 +690,7 @@ public class SimpleChildQuerySearchTests extends AbstractSharedClusterTest {
.global(true)
)
.execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getFailedShards(), equalTo(0));
assertThat(searchResponse.getHits().totalHits(), equalTo(2l));
assertThat(searchResponse.getHits().getAt(0).id(), anyOf(equalTo("p2"), equalTo("p1")));
@ -744,7 +745,7 @@ public class SimpleChildQuerySearchTests extends AbstractSharedClusterTest {
assertThat(searchResponse.getHits().getAt(0).sourceAsString(), containsString("\"p_value1\""));
searchResponse = client().prepareSearch("test").setQuery(constantScoreQuery(hasChildFilter("child", termQuery("c_field", "yellow")))).execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getFailedShards(), equalTo(0));
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("p1"));
@ -756,14 +757,14 @@ public class SimpleChildQuerySearchTests extends AbstractSharedClusterTest {
client().admin().indices().prepareRefresh().execute().actionGet();
searchResponse = client().prepareSearch("test").setQuery(topChildrenQuery("child", termQuery("c_field", "yellow"))).execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getFailedShards(), equalTo(0));
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("p1"));
assertThat(searchResponse.getHits().getAt(0).sourceAsString(), containsString("\"p_value1_updated\""));
searchResponse = client().prepareSearch("test").setQuery(constantScoreQuery(hasChildFilter("child", termQuery("c_field", "yellow")))).execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getFailedShards(), equalTo(0));
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("p1"));
@ -797,17 +798,17 @@ public class SimpleChildQuerySearchTests extends AbstractSharedClusterTest {
SearchResponse searchResponse = client().prepareSearch("test").setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
.setQuery(boolQuery().mustNot(hasChildQuery("child", boolQuery().should(queryString("c_field:*")))))
.execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
searchResponse = client().prepareSearch("test").setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
.setQuery(boolQuery().mustNot(hasParentQuery("parent", boolQuery().should(queryString("p_field:*")))))
.execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
searchResponse = client().prepareSearch("test").setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
.setQuery(boolQuery().mustNot(topChildrenQuery("child", boolQuery().should(queryString("c_field:*")))))
.execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
}
@Test
@ -833,7 +834,7 @@ public class SimpleChildQuerySearchTests extends AbstractSharedClusterTest {
SearchResponse searchResponse = client().prepareSearch("test").setSearchType(SearchType.QUERY_THEN_FETCH)
.setQuery(boolQuery().mustNot(topChildrenQuery("child", boolQuery().should(queryString("c_field:*")))))
.execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
}
@Test
@ -876,7 +877,7 @@ public class SimpleChildQuerySearchTests extends AbstractSharedClusterTest {
SearchResponse searchResponse = client().prepareSearch("test")
.setQuery(topChildrenQuery("child", termQuery("c_field1", "p3")))
.execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getFailedShards(), equalTo(0));
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("p3"));
@ -884,7 +885,7 @@ public class SimpleChildQuerySearchTests extends AbstractSharedClusterTest {
searchResponse = client().prepareSearch("test")
.setQuery(topChildrenQuery("child", termQuery("c_field2", "even")))
.execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getFailedShards(), equalTo(0));
assertThat(searchResponse.getHits().totalHits(), equalTo(2l));
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("p2"));
@ -921,14 +922,14 @@ public class SimpleChildQuerySearchTests extends AbstractSharedClusterTest {
SearchResponse searchResponse = client().prepareSearch("test")
.setQuery(filteredQuery(matchAllQuery(), hasChildFilter("child", matchAllQuery())))
.execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getFailedShards(), equalTo(0));
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
searchResponse = client().prepareSearch("test")
.setQuery(filteredQuery(matchAllQuery(), hasParentFilter("parent", matchAllQuery())))
.execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getFailedShards(), equalTo(0));
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
}
@ -1270,7 +1271,7 @@ public class SimpleChildQuerySearchTests extends AbstractSharedClusterTest {
SearchResponse searchResponse = client().prepareSearch("test")
.setQuery(filteredQuery(matchAllQuery(), hasChildFilter("child", termFilter("c_field", 1))))
.execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getFailedShards(), equalTo(0));
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
assertThat(searchResponse.getHits().hits()[0].id(), equalTo("1"));
@ -1278,7 +1279,7 @@ public class SimpleChildQuerySearchTests extends AbstractSharedClusterTest {
searchResponse = client().prepareSearch("test")
.setQuery(filteredQuery(matchAllQuery(), hasParentFilter("parent", termFilter("p_field", 1))))
.execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getFailedShards(), equalTo(0));
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
assertThat(searchResponse.getHits().hits()[0].id(), equalTo("2"));
@ -1324,7 +1325,7 @@ public class SimpleChildQuerySearchTests extends AbstractSharedClusterTest {
.addSort("p_field", SortOrder.ASC)
.setSize(5)
.execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(10L));
assertThat(searchResponse.getHits().hits()[0].id(), equalTo("p000"));
assertThat(searchResponse.getHits().hits()[1].id(), equalTo("p001"));
@ -1337,7 +1338,7 @@ public class SimpleChildQuerySearchTests extends AbstractSharedClusterTest {
.addSort("c_field", SortOrder.ASC)
.setSize(5)
.execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(500L));
assertThat(searchResponse.getHits().hits()[0].id(), equalTo("c000"));
assertThat(searchResponse.getHits().hits()[1].id(), equalTo("c001"));
@ -1350,7 +1351,7 @@ public class SimpleChildQuerySearchTests extends AbstractSharedClusterTest {
.addSort("p_field", SortOrder.ASC)
.setSize(5)
.execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(10L));
assertThat(searchResponse.getHits().hits()[0].id(), equalTo("p000"));
assertThat(searchResponse.getHits().hits()[1].id(), equalTo("p001"));
@ -1389,7 +1390,7 @@ public class SimpleChildQuerySearchTests extends AbstractSharedClusterTest {
SearchResponse searchResponse = client().prepareSearch("test")
.setQuery(hasChildQuery("child", termQuery("c_field", "yellow")).scoreType("sum"))
.execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getFailedShards(), equalTo(0));
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("p1"));
@ -1402,7 +1403,7 @@ public class SimpleChildQuerySearchTests extends AbstractSharedClusterTest {
.must(hasParentQuery("parent", termQuery("p_field", "p_value2")).scoreType("score"))
)
.execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getFailedShards(), equalTo(0));
assertThat(searchResponse.getHits().totalHits(), equalTo(2l));
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("c3"));
@ -1420,7 +1421,7 @@ public class SimpleChildQuerySearchTests extends AbstractSharedClusterTest {
searchResponse = client().prepareSearch("test")
.setQuery(hasChildQuery("child", termQuery("c_field", "yellow")).scoreType("sum"))
.execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getFailedShards(), equalTo(0));
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("p1"));
@ -1433,7 +1434,7 @@ public class SimpleChildQuerySearchTests extends AbstractSharedClusterTest {
.must(hasParentQuery("parent", termQuery("p_field", "p_value2")).scoreType("score"))
)
.execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getFailedShards(), equalTo(0));
assertThat(searchResponse.getHits().totalHits(), equalTo(2l));
assertThat(searchResponse.getHits().getAt(0).id(), Matchers.anyOf(equalTo("c3"), equalTo("c4")));
@ -1469,7 +1470,7 @@ public class SimpleChildQuerySearchTests extends AbstractSharedClusterTest {
.setQuery(hasChildQuery("child", matchAllQuery()).scoreType("sum"))
.setMinScore(2) // Score needs to be above 2.0!
.execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getFailedShards(), equalTo(0));
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("p2"));

View File

@ -30,7 +30,6 @@ import org.elasticsearch.test.integration.AbstractSharedClusterTest;
import org.junit.Test;
import java.io.IOException;
import java.util.Arrays;
import static org.elasticsearch.client.Requests.*;
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
@ -38,10 +37,12 @@ import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.index.query.FilterBuilders.termFilter;
import static org.elasticsearch.index.query.QueryBuilders.*;
import static org.elasticsearch.search.builder.SearchSourceBuilder.searchSource;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchHits;
import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.equalTo;
/**
*
*/
@ -69,7 +70,7 @@ public class CustomScoreSearchTests extends AbstractSharedClusterTest {
.setExplain(true)
.execute().actionGet();
assertThat(Arrays.toString(searchResponse.getShardFailures()), searchResponse.getFailedShards(), equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(4l));
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("2"));
@ -99,7 +100,7 @@ public class CustomScoreSearchTests extends AbstractSharedClusterTest {
.setExplain(true)
.execute().actionGet();
assertThat(Arrays.toString(searchResponse.getShardFailures()), searchResponse.getFailedShards(), equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(4l));
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("2"));
@ -336,7 +337,7 @@ public class CustomScoreSearchTests extends AbstractSharedClusterTest {
.setQuery(customFiltersScoreQuery(fuzzyQuery("field", "value"))
.add(FilterBuilders.idsFilter("type").addIds("1"), 3))
.execute().actionGet();
assertThat(Arrays.toString(searchResponse.getShardFailures()), searchResponse.getFailedShards(), equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(4l));
}
@ -360,7 +361,7 @@ public class CustomScoreSearchTests extends AbstractSharedClusterTest {
.setExplain(true)
.execute().actionGet();
assertThat(Arrays.toString(searchResponse.getShardFailures()), searchResponse.getFailedShards(), equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(4l));
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("2"));
@ -380,7 +381,7 @@ public class CustomScoreSearchTests extends AbstractSharedClusterTest {
.setExplain(true)
.execute().actionGet();
assertThat(Arrays.toString(searchResponse.getShardFailures()), searchResponse.getFailedShards(), equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(4l));
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("2"));
@ -401,7 +402,7 @@ public class CustomScoreSearchTests extends AbstractSharedClusterTest {
.setExplain(true)
.execute().actionGet();
assertThat(Arrays.toString(searchResponse.getShardFailures()), searchResponse.getFailedShards(), equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(4l));
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("1"));
assertThat(searchResponse.getHits().getAt(0).score(), equalTo(8.0f));
@ -415,7 +416,7 @@ public class CustomScoreSearchTests extends AbstractSharedClusterTest {
.setExplain(true)
.execute().actionGet();
assertThat(Arrays.toString(searchResponse.getShardFailures()), searchResponse.getFailedShards(), equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(4l));
assertThat(searchResponse.getHits().getAt(0).id(), anyOf(equalTo("1"), equalTo("3"))); // could be both depending on the order of the docs internally (lucene order)
assertThat(searchResponse.getHits().getAt(0).score(), equalTo(5.0f));
@ -429,7 +430,7 @@ public class CustomScoreSearchTests extends AbstractSharedClusterTest {
.setExplain(true)
.execute().actionGet();
assertThat(Arrays.toString(searchResponse.getShardFailures()), searchResponse.getFailedShards(), equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(4l));
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("3"));
assertThat(searchResponse.getHits().getAt(0).score(), equalTo(5.0f));
@ -446,7 +447,7 @@ public class CustomScoreSearchTests extends AbstractSharedClusterTest {
.setExplain(true)
.execute().actionGet();
assertThat(Arrays.toString(searchResponse.getShardFailures()), searchResponse.getFailedShards(), equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(4l));
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("3"));
assertThat(searchResponse.getHits().getAt(0).score(), equalTo(5.0f));
@ -466,7 +467,7 @@ public class CustomScoreSearchTests extends AbstractSharedClusterTest {
.setExplain(true)
.execute().actionGet();
assertThat(Arrays.toString(searchResponse.getShardFailures()), searchResponse.getFailedShards(), equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(4l));
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("1"));
assertThat(searchResponse.getHits().getAt(0).score(), equalTo(15.0f));
@ -486,7 +487,7 @@ public class CustomScoreSearchTests extends AbstractSharedClusterTest {
.setExplain(true)
.execute().actionGet();
assertThat(Arrays.toString(searchResponse.getShardFailures()), searchResponse.getFailedShards(), equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(4l));
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("2"));
assertThat(searchResponse.getHits().getAt(0).score(), equalTo(searchResponse.getHits().getAt(0).explanation().getValue()));
@ -507,7 +508,7 @@ public class CustomScoreSearchTests extends AbstractSharedClusterTest {
.setExplain(true)
.execute().actionGet();
assertThat(Arrays.toString(searchResponse.getShardFailures()), searchResponse.getFailedShards(), equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(4l));
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("1"));
assertThat(searchResponse.getHits().getAt(0).score(), equalTo(searchResponse.getHits().getAt(0).explanation().getValue()));

View File

@ -41,7 +41,7 @@ import java.util.Map;
import static org.elasticsearch.client.Requests.refreshRequest;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
import static org.hamcrest.Matchers.*;
/**
@ -147,7 +147,7 @@ public class SearchFieldsTests extends AbstractSharedClusterTest {
.addScriptField("date1", "doc['date'].date.millis")
.execute().actionGet();
assertThat("Failures " + Arrays.toString(response.getShardFailures()), response.getShardFailures().length, equalTo(0));
assertNoFailures(response);
assertThat(response.getHits().totalHits(), equalTo(3l));
assertThat(response.getHits().getAt(0).isSourceEmpty(), equalTo(true));

View File

@ -19,16 +19,6 @@
package org.elasticsearch.test.integration.search.geo;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
import static org.elasticsearch.search.facet.FacetBuilders.geoDistanceFacet;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.closeTo;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.not;
import java.util.Arrays;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.common.Priority;
import org.elasticsearch.common.unit.DistanceUnit;
@ -37,6 +27,12 @@ import org.elasticsearch.search.facet.geodistance.GeoDistanceFacet;
import org.elasticsearch.test.integration.AbstractSharedClusterTest;
import org.junit.Test;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
import static org.elasticsearch.search.facet.FacetBuilders.geoDistanceFacet;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
import static org.hamcrest.Matchers.*;
/**
*
*/
@ -248,7 +244,7 @@ public class GeoDistanceFacetTests extends AbstractSharedClusterTest {
)
.execute().actionGet();
assertThat(Arrays.toString(searchResponse.getShardFailures()), searchResponse.getFailedShards(), equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(2l));
GeoDistanceFacet facet = searchResponse.getFacets().facet("geo1");

View File

@ -40,7 +40,6 @@ import org.elasticsearch.test.integration.AbstractSharedClusterTest;
import org.junit.Test;
import java.io.IOException;
import java.util.Arrays;
import static org.elasticsearch.action.search.SearchType.QUERY_THEN_FETCH;
import static org.elasticsearch.client.Requests.searchRequest;
@ -50,6 +49,7 @@ import static org.elasticsearch.index.query.QueryBuilders.*;
import static org.elasticsearch.search.builder.SearchSourceBuilder.highlight;
import static org.elasticsearch.search.builder.SearchSourceBuilder.searchSource;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHighlight;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.startsWith;
@ -402,7 +402,7 @@ public class HighlighterSearchTests extends AbstractSharedClusterTest {
.addHighlightedField("title", -1, 0)
.execute().actionGet();
assertThat(Arrays.toString(search.getShardFailures()), search.getFailedShards(), equalTo(0));
assertNoFailures(search);
assertThat(search.getHits().totalHits(), equalTo(5l));
assertThat(search.getHits().hits().length, equalTo(5));
@ -416,7 +416,7 @@ public class HighlighterSearchTests extends AbstractSharedClusterTest {
.addHighlightedField("attachments.body", -1, 0)
.execute().actionGet();
assertThat(Arrays.toString(search.getShardFailures()), search.getFailedShards(), equalTo(0));
assertNoFailures(search);
assertThat(search.getHits().totalHits(), equalTo(5l));
assertThat(search.getHits().hits().length, equalTo(5));
@ -452,7 +452,7 @@ public class HighlighterSearchTests extends AbstractSharedClusterTest {
.addHighlightedField("title", -1, 0)
.execute().actionGet();
assertThat(Arrays.toString(search.getShardFailures()), search.getFailedShards(), equalTo(0));
assertNoFailures(search);
assertThat(search.getHits().totalHits(), equalTo(5l));
assertThat(search.getHits().hits().length, equalTo(5));
@ -466,7 +466,7 @@ public class HighlighterSearchTests extends AbstractSharedClusterTest {
.addHighlightedField("attachments.body", -1, 2)
.execute().actionGet();
assertThat(Arrays.toString(search.getShardFailures()), search.getFailedShards(), equalTo(0));
assertNoFailures(search);
assertThat(search.getHits().totalHits(), equalTo(5l));
assertThat(search.getHits().hits().length, equalTo(5));
@ -558,7 +558,7 @@ public class HighlighterSearchTests extends AbstractSharedClusterTest {
.field(new HighlightBuilder.Field("field2").preTags("<field2>").postTags("</field2>")));
SearchResponse searchResponse = client().search(searchRequest("test").source(source).searchType(QUERY_THEN_FETCH).scroll(timeValueMinutes(10))).actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
assertThat(searchResponse.getHits().getAt(0).highlightFields().get("field1").fragments()[0].string(), equalTo("this is a <global>test</global>"));
@ -581,7 +581,7 @@ public class HighlighterSearchTests extends AbstractSharedClusterTest {
.highlight(highlight().field("field*").order("score").preTags("<xxx>").postTags("</xxx>"));
SearchResponse searchResponse = client().search(searchRequest("test").source(source).searchType(QUERY_THEN_FETCH).scroll(timeValueMinutes(10))).actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
assertThat(searchResponse.getHits().getAt(0).highlightFields().get("field1").fragments()[0].string(), equalTo("this is a <xxx>test</xxx>"));
@ -604,7 +604,7 @@ public class HighlighterSearchTests extends AbstractSharedClusterTest {
.highlight(highlight().field("field1").order("score").preTags("<xxx>").postTags("</xxx>"));
SearchResponse searchResponse = client().search(searchRequest("test").source(source).searchType(QUERY_THEN_FETCH).scroll(timeValueMinutes(10))).actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
assertThat(searchResponse.getHits().getAt(0).highlightFields().get("field1").fragments()[0].string(), equalTo("this is a <xxx>test</xxx>"));
@ -616,7 +616,7 @@ public class HighlighterSearchTests extends AbstractSharedClusterTest {
.highlight(highlight().field("field1").order("score").preTags("<xxx>").postTags("</xxx>"));
searchResponse = client().search(searchRequest("test").source(source).searchType(QUERY_THEN_FETCH).scroll(timeValueMinutes(10))).actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
assertThat(searchResponse.getHits().getAt(0).highlightFields().get("field1").fragments()[0].string(), equalTo("this is a <xxx>test</xxx>"));
@ -628,7 +628,7 @@ public class HighlighterSearchTests extends AbstractSharedClusterTest {
.highlight(highlight().field("field2").order("score").preTags("<xxx>").postTags("</xxx>"));
searchResponse = client().search(searchRequest("test").source(source).searchType(QUERY_THEN_FETCH).scroll(timeValueMinutes(10))).actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
assertThat(searchResponse.getHits().getAt(0).highlightFields().get("field2").fragments()[0].string(), equalTo("The <xxx>quick</xxx> brown fox jumps over the lazy dog"));
@ -640,7 +640,7 @@ public class HighlighterSearchTests extends AbstractSharedClusterTest {
.highlight(highlight().field("field2").order("score").preTags("<xxx>").postTags("</xxx>"));
searchResponse = client().search(searchRequest("test").source(source).searchType(QUERY_THEN_FETCH).scroll(timeValueMinutes(10))).actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
assertThat(searchResponse.getHits().getAt(0).highlightFields().get("field2").fragments()[0].string(), equalTo("The <xxx>quick</xxx> brown fox jumps over the lazy dog"));
@ -652,7 +652,7 @@ public class HighlighterSearchTests extends AbstractSharedClusterTest {
.highlight(highlight().field("field2").order("score").preTags("<xxx>").postTags("</xxx>"));
searchResponse = client().search(searchRequest("test").source(source).searchType(QUERY_THEN_FETCH).scroll(timeValueMinutes(10))).actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
assertThat(searchResponse.getHits().getAt(0).highlightFields().get("field2").fragments()[0].string(), equalTo("The <xxx>quick</xxx> brown fox jumps over the lazy dog"));
@ -664,7 +664,7 @@ public class HighlighterSearchTests extends AbstractSharedClusterTest {
.highlight(highlight().field("field2").order("score").preTags("<xxx>").postTags("</xxx>"));
searchResponse = client().search(searchRequest("test").source(source).searchType(QUERY_THEN_FETCH).scroll(timeValueMinutes(10))).actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
assertThat(searchResponse.getHits().getAt(0).highlightFields().get("field2").fragments()[0].string(), equalTo("The <xxx>quick</xxx> brown fox jumps over the lazy dog"));
}
@ -685,7 +685,7 @@ public class HighlighterSearchTests extends AbstractSharedClusterTest {
.highlight(highlight().field("field1", 100, 0).order("score").preTags("<xxx>").postTags("</xxx>"));
SearchResponse searchResponse = client().search(searchRequest("test").source(source).searchType(QUERY_THEN_FETCH).scroll(timeValueMinutes(10))).actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
assertThat(searchResponse.getHits().getAt(0).highlightFields().get("field1").fragments()[0].string(), equalTo("this is a <xxx>test</xxx>"));
@ -697,7 +697,7 @@ public class HighlighterSearchTests extends AbstractSharedClusterTest {
.highlight(highlight().field("field1", 100, 0).order("score").preTags("<xxx>").postTags("</xxx>"));
searchResponse = client().search(searchRequest("test").source(source).searchType(QUERY_THEN_FETCH).scroll(timeValueMinutes(10))).actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
// LUCENE 3.1 UPGRADE: Caused adding the space at the end...
@ -710,7 +710,7 @@ public class HighlighterSearchTests extends AbstractSharedClusterTest {
.highlight(highlight().field("field2", 100, 0).order("score").preTags("<xxx>").postTags("</xxx>"));
searchResponse = client().search(searchRequest("test").source(source).searchType(QUERY_THEN_FETCH).scroll(timeValueMinutes(10))).actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
// LUCENE 3.1 UPGRADE: Caused adding the space at the end...
@ -723,7 +723,7 @@ public class HighlighterSearchTests extends AbstractSharedClusterTest {
.highlight(highlight().field("field2", 100, 0).order("score").preTags("<xxx>").postTags("</xxx>"));
searchResponse = client().search(searchRequest("test").source(source).searchType(QUERY_THEN_FETCH).scroll(timeValueMinutes(10))).actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
// LUCENE 3.1 UPGRADE: Caused adding the space at the end...
@ -845,7 +845,7 @@ public class HighlighterSearchTests extends AbstractSharedClusterTest {
.addHighlightedField("title", 30, 1, 10)
.execute().actionGet();
assertThat(Arrays.toString(search.getShardFailures()), search.getFailedShards(), equalTo(0));
assertNoFailures(search);
assertThat(search.getHits().totalHits(), equalTo(5l));
assertThat(search.getHits().hits().length, equalTo(5));
@ -876,7 +876,7 @@ public class HighlighterSearchTests extends AbstractSharedClusterTest {
.addHighlightedField("title", 50, 1, 10)
.execute().actionGet();
assertThat(Arrays.toString(search.getShardFailures()), search.getFailedShards(), equalTo(0));
assertNoFailures(search);
assertThat(search.getHits().totalHits(), equalTo(5l));
@ -909,7 +909,7 @@ public class HighlighterSearchTests extends AbstractSharedClusterTest {
.execute().actionGet();
assertThat(Arrays.toString(search.getShardFailures()), search.getFailedShards(), equalTo(0));
assertNoFailures(search);
assertThat(search.getHits().totalHits(), equalTo(5l));
assertThat(search.getHits().hits().length, equalTo(5));
@ -949,7 +949,7 @@ public class HighlighterSearchTests extends AbstractSharedClusterTest {
.setHighlighterEncoder("html")
.addHighlightedField("title.key", 50, 1)
.execute().actionGet();
assertThat(Arrays.toString(search.getShardFailures()), search.getFailedShards(), equalTo(0));
assertNoFailures(search);
hit = search.getHits().getAt(0);
assertThat(hit.highlightFields().get("title.key").fragments()[0].string(), equalTo("<em>this</em> <em>is</em> <em>a</em> <em>test</em>"));
@ -977,7 +977,7 @@ public class HighlighterSearchTests extends AbstractSharedClusterTest {
.setHighlighterEncoder("html")
.addHighlightedField("title", 50, 1)
.execute().actionGet();
assertThat(Arrays.toString(search.getShardFailures()), search.getFailedShards(), equalTo(0));
assertNoFailures(search);
SearchHit hit = search.getHits().getAt(0);
assertThat(hit.highlightFields().get("title").fragments()[0].string(), equalTo("this is a <em>test</em>"));
@ -988,7 +988,7 @@ public class HighlighterSearchTests extends AbstractSharedClusterTest {
.setHighlighterEncoder("html")
.addHighlightedField("title.key", 50, 1)
.execute().actionGet();
assertThat(Arrays.toString(search.getShardFailures()), search.getFailedShards(), equalTo(0));
assertNoFailures(search);
hit = search.getHits().getAt(0);
assertThat(hit.highlightFields().get("title.key").fragments()[0].string(), equalTo("<em>this</em> <em>is</em> <em>a</em> <em>test</em>"));
@ -1015,7 +1015,7 @@ public class HighlighterSearchTests extends AbstractSharedClusterTest {
.setHighlighterEncoder("html")
.addHighlightedField("title", 50, 1)
.execute().actionGet();
assertThat(Arrays.toString(search.getShardFailures()), search.getFailedShards(), equalTo(0));
assertNoFailures(search);
SearchHit hit = search.getHits().getAt(0);
assertThat(hit.highlightFields().get("title").fragments()[0].string(), equalTo("this is a <em>test</em>"));
@ -1026,7 +1026,7 @@ public class HighlighterSearchTests extends AbstractSharedClusterTest {
.setHighlighterEncoder("html")
.addHighlightedField("title.key", 50, 1)
.execute().actionGet();
assertThat(Arrays.toString(search.getShardFailures()), search.getFailedShards(), equalTo(0));
assertNoFailures(search);
hit = search.getHits().getAt(0);
assertThat(hit.highlightFields().get("title.key").fragments()[0].string(), equalTo("<em>this</em> <em>is</em> <em>a</em> <em>test</em>"));
@ -1053,7 +1053,7 @@ public class HighlighterSearchTests extends AbstractSharedClusterTest {
.setHighlighterEncoder("html")
.addHighlightedField("title", 50, 1)
.execute().actionGet();
assertThat(Arrays.toString(search.getShardFailures()), search.getFailedShards(), equalTo(0));
assertNoFailures(search);
SearchHit hit = search.getHits().getAt(0);
assertThat(hit.highlightFields().get("title").fragments()[0].string(), equalTo("this is a <em>test</em>"));
@ -1064,7 +1064,7 @@ public class HighlighterSearchTests extends AbstractSharedClusterTest {
.setHighlighterEncoder("html")
.addHighlightedField("title.key", 50, 1)
.execute().actionGet();
assertThat(Arrays.toString(search.getShardFailures()), search.getFailedShards(), equalTo(0));
assertNoFailures(search);
hit = search.getHits().getAt(0);
assertThat(hit.highlightFields().get("title.key").fragments()[0].string(), equalTo("<em>this</em> <em>is</em> <em>a</em> <em>test</em>"));
@ -1090,7 +1090,7 @@ public class HighlighterSearchTests extends AbstractSharedClusterTest {
.addHighlightedField("title", 50, 1, 10)
.execute().actionGet();
assertThat(Arrays.toString(search.getShardFailures()), search.getFailedShards(), equalTo(0));
assertNoFailures(search);
search = client().prepareSearch()
.setQuery(matchPhraseQuery("title", "this is a test"))
@ -1146,7 +1146,7 @@ public class HighlighterSearchTests extends AbstractSharedClusterTest {
.highlight(highlight().field("field2").order("score").preTags("<x>").postTags("</x>"));
SearchResponse searchResponse = client().search(searchRequest("test").source(source).searchType(QUERY_THEN_FETCH).scroll(timeValueMinutes(10))).actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
assertThat(searchResponse.getHits().getAt(0).highlightFields().get("field2").fragments()[0].string(), equalTo("The quick <x>brown</x> fox jumps over the lazy dog"));
@ -1168,7 +1168,7 @@ public class HighlighterSearchTests extends AbstractSharedClusterTest {
SearchResponse searchResponse = client().search(
searchRequest("test").source(source).searchType(QUERY_THEN_FETCH).scroll(timeValueMinutes(10))).actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
assertThat(searchResponse.getHits().getAt(0).highlightFields().get("field2").fragments()[0].string(),
@ -1193,7 +1193,7 @@ public class HighlighterSearchTests extends AbstractSharedClusterTest {
.highlight(highlight().field("field2").order("score").preTags("<x>").postTags("</x>"));
SearchResponse searchResponse = client().search(searchRequest("test").source(source).searchType(QUERY_THEN_FETCH).scroll(timeValueMinutes(10))).actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
assertThat(searchResponse.getHits().getAt(0).highlightFields().get("field2").fragments()[0].string(), equalTo("The <x>quick</x> <x>brown</x> fox jumps over the lazy dog"));
@ -1213,7 +1213,7 @@ public class HighlighterSearchTests extends AbstractSharedClusterTest {
SearchResponse searchResponse = client().search(
searchRequest("test").source(source).searchType(QUERY_THEN_FETCH).scroll(timeValueMinutes(10))).actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
assertThat(searchResponse.getHits().getAt(0).highlightFields().get("field2").fragments()[0].string(),
@ -1255,7 +1255,7 @@ public class HighlighterSearchTests extends AbstractSharedClusterTest {
.highlight(highlight().field("field0").order("score").preTags("<x>").postTags("</x>"));
SearchResponse searchResponse = client().search(searchRequest("test").source(source).searchType(QUERY_THEN_FETCH)).actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
assertThat(searchResponse.getHits().getAt(0).highlightFields().get("field0").fragments()[0].string(), equalTo("The <x>quick</x> <x>brown</x> fox jumps over the lazy dog"));
@ -1267,7 +1267,7 @@ public class HighlighterSearchTests extends AbstractSharedClusterTest {
.highlight(highlight().field("field1").order("score").preTags("<x>").postTags("</x>"));
searchResponse = client().search(searchRequest("test").source(source).searchType(QUERY_THEN_FETCH)).actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(2l));
assertThat(searchResponse.getHits().getAt(0).highlightFields().get("field1").fragments()[0].string(), equalTo("The <x>quick browse</x> button is a fancy thing, right bro?"));
@ -1287,7 +1287,7 @@ public class HighlighterSearchTests extends AbstractSharedClusterTest {
.highlight(highlight().field("field3").order("score").preTags("<x>").postTags("</x>"));
searchResponse = client().search(searchRequest("test").source(source).searchType(QUERY_THEN_FETCH)).actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
assertThat(searchResponse.getHits().getAt(0).highlightFields().get("field3").fragments()[0].string(),
@ -1298,7 +1298,7 @@ public class HighlighterSearchTests extends AbstractSharedClusterTest {
.highlight(highlight().field("field4").order("score").preTags("<x>").postTags("</x>"));
searchResponse = client().search(searchRequest("test").source(source).searchType(QUERY_THEN_FETCH)).actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(2l));
assertThat(searchResponse.getHits().getAt(0).highlightFields().get("field4").fragments()[0].string(),
@ -1311,7 +1311,7 @@ public class HighlighterSearchTests extends AbstractSharedClusterTest {
.highlight(highlight().field("field4").order("score").preTags("<x>").postTags("</x>"));
searchResponse = client().search(searchRequest("test").source(source).searchType(QUERY_THEN_FETCH)).actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
assertThat(searchResponse.getHits().getAt(0).highlightFields().get("field4").fragments()[0].string(),

View File

@ -29,7 +29,9 @@ import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.index.query.FilterBuilders.*;
import static org.elasticsearch.index.query.QueryBuilders.filteredQuery;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
import static org.hamcrest.Matchers.*;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasItemInArray;
/**
*
@ -64,7 +66,7 @@ public class MatchedFiltersTests extends AbstractSharedClusterTest {
.execute().actionGet();
assertThat(searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(3l));
for (SearchHit hit : searchResponse.getHits()) {
if (hit.id().equals("1") || hit.id().equals("2")) {

View File

@ -34,7 +34,6 @@ import org.elasticsearch.test.integration.AbstractSharedClusterTest;
import org.junit.Test;
import java.io.IOException;
import java.util.Arrays;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.index.query.FilterBuilders.*;
@ -482,19 +481,19 @@ public class SimpleQueryTests extends AbstractSharedClusterTest {
client().prepareIndex("test", "type1", "1").setSource("field1", "value1").execute().actionGet();
refresh();
SearchResponse searchResponse = client().prepareSearch("test").setQuery(constantScoreQuery(termsFilter("field1", "value1").cacheKey("test1"))).execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
searchResponse = client().prepareSearch("test").setQuery(constantScoreQuery(termsFilter("field1", "value1").cacheKey("test1"))).execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
searchResponse = client().prepareSearch("test").setQuery(constantScoreQuery(termsFilter("field1", "value1"))).execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
searchResponse = client().prepareSearch("test").setQuery(constantScoreQuery(termsFilter("field1", "value1"))).execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
}
@ -728,21 +727,21 @@ public class SimpleQueryTests extends AbstractSharedClusterTest {
SearchResponse searchResponse = client().prepareSearch()
.setQuery(queryString("str:kimcy~1"))
.execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("1"));
searchResponse = client().prepareSearch()
.setQuery(queryString("num:11~1"))
.execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("1"));
searchResponse = client().prepareSearch()
.setQuery(queryString("date:2012-02-02~1d"))
.execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
}
@ -756,45 +755,45 @@ public class SimpleQueryTests extends AbstractSharedClusterTest {
SearchResponse searchResponse = client().prepareSearch()
.setQuery(queryString("num:>19"))
.execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("2"));
searchResponse = client().prepareSearch()
.setQuery(queryString("num:>20"))
.execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(0l));
searchResponse = client().prepareSearch()
.setQuery(queryString("num:>=20"))
.execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("2"));
searchResponse = client().prepareSearch()
.setQuery(queryString("num:>11"))
.execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(2l));
searchResponse = client().prepareSearch()
.setQuery(queryString("num:<20"))
.execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
searchResponse = client().prepareSearch()
.setQuery(queryString("num:<=20"))
.execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(2l));
searchResponse = client().prepareSearch()
.setQuery(queryString("+num:>11 +num:<20"))
.execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
}
@ -858,7 +857,7 @@ public class SimpleQueryTests extends AbstractSharedClusterTest {
SearchResponse searchResponse = client().prepareSearch("test")
.setQuery(filteredQuery(matchAllQuery(), termsLookupFilter("term").lookupIndex("lookup").lookupType("type").lookupId("1").lookupPath("terms"))
).execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().getTotalHits(), equalTo(2l));
assertThat(searchResponse.getHits().getHits()[0].getId(), anyOf(equalTo("1"), equalTo("3")));
assertThat(searchResponse.getHits().getHits()[1].getId(), anyOf(equalTo("1"), equalTo("3")));
@ -867,7 +866,7 @@ public class SimpleQueryTests extends AbstractSharedClusterTest {
searchResponse = client().prepareSearch("test")
.setQuery(filteredQuery(matchAllQuery(), termsLookupFilter("_id").lookupIndex("lookup").lookupType("type").lookupId("1").lookupPath("terms"))
).execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().getTotalHits(), equalTo(2l));
assertThat(searchResponse.getHits().getHits()[0].getId(), anyOf(equalTo("1"), equalTo("3")));
assertThat(searchResponse.getHits().getHits()[1].getId(), anyOf(equalTo("1"), equalTo("3")));
@ -876,7 +875,7 @@ public class SimpleQueryTests extends AbstractSharedClusterTest {
searchResponse = client().prepareSearch("test")
.setQuery(filteredQuery(matchAllQuery(), termsLookupFilter("term").lookupIndex("lookup").lookupType("type").lookupId("1").lookupPath("terms"))
).execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().getTotalHits(), equalTo(2l));
assertThat(searchResponse.getHits().getHits()[0].getId(), anyOf(equalTo("1"), equalTo("3")));
assertThat(searchResponse.getHits().getHits()[1].getId(), anyOf(equalTo("1"), equalTo("3")));
@ -884,14 +883,14 @@ public class SimpleQueryTests extends AbstractSharedClusterTest {
searchResponse = client().prepareSearch("test")
.setQuery(filteredQuery(matchAllQuery(), termsLookupFilter("term").lookupIndex("lookup").lookupType("type").lookupId("2").lookupPath("terms"))
).execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l));
assertThat(searchResponse.getHits().getHits()[0].getId(), anyOf(equalTo("1"), equalTo("2")));
searchResponse = client().prepareSearch("test")
.setQuery(filteredQuery(matchAllQuery(), termsLookupFilter("term").lookupIndex("lookup").lookupType("type").lookupId("3").lookupPath("terms"))
).execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().getTotalHits(), equalTo(2l));
assertThat(searchResponse.getHits().getHits()[0].getId(), anyOf(equalTo("2"), equalTo("4")));
assertThat(searchResponse.getHits().getHits()[1].getId(), anyOf(equalTo("2"), equalTo("4")));
@ -899,14 +898,14 @@ public class SimpleQueryTests extends AbstractSharedClusterTest {
searchResponse = client().prepareSearch("test")
.setQuery(filteredQuery(matchAllQuery(), termsLookupFilter("term").lookupIndex("lookup").lookupType("type").lookupId("4").lookupPath("terms"))
).execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().getTotalHits(), equalTo(0l));
searchResponse = client().prepareSearch("test")
.setQuery(filteredQuery(matchAllQuery(), termsLookupFilter("term").lookupIndex("lookup2").lookupType("type").lookupId("1").lookupPath("arr.term"))
).execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().getTotalHits(), equalTo(2l));
assertThat(searchResponse.getHits().getHits()[0].getId(), anyOf(equalTo("1"), equalTo("3")));
assertThat(searchResponse.getHits().getHits()[1].getId(), anyOf(equalTo("1"), equalTo("3")));
@ -914,14 +913,14 @@ public class SimpleQueryTests extends AbstractSharedClusterTest {
searchResponse = client().prepareSearch("test")
.setQuery(filteredQuery(matchAllQuery(), termsLookupFilter("term").lookupIndex("lookup2").lookupType("type").lookupId("2").lookupPath("arr.term"))
).execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l));
assertThat(searchResponse.getHits().getHits()[0].getId(), anyOf(equalTo("1"), equalTo("2")));
searchResponse = client().prepareSearch("test")
.setQuery(filteredQuery(matchAllQuery(), termsLookupFilter("term").lookupIndex("lookup2").lookupType("type").lookupId("3").lookupPath("arr.term"))
).execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().getTotalHits(), equalTo(2l));
assertThat(searchResponse.getHits().getHits()[0].getId(), anyOf(equalTo("2"), equalTo("4")));
assertThat(searchResponse.getHits().getHits()[1].getId(), anyOf(equalTo("2"), equalTo("4")));
@ -929,7 +928,7 @@ public class SimpleQueryTests extends AbstractSharedClusterTest {
searchResponse = client().prepareSearch("test")
.setQuery(filteredQuery(matchAllQuery(), termsLookupFilter("not_exists").lookupIndex("lookup2").lookupType("type").lookupId("3").lookupPath("arr.term"))
).execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().getTotalHits(), equalTo(0l));
}
@ -1269,7 +1268,7 @@ public class SimpleQueryTests extends AbstractSharedClusterTest {
.setQuery(QueryBuilders.matchAllQuery())
.setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
.execute().actionGet();
assertThat(response.getShardFailures().length, equalTo(0));
assertNoFailures(response);
assertThat(response.getHits().totalHits(), equalTo(4l));
response = client().prepareSearch("test").setQuery(

View File

@ -552,7 +552,7 @@ public class SimpleSortTests extends AbstractSharedClusterTest {
.setQuery(matchAllQuery())
.addSort(SortBuilders.scriptSort("\u0027\u0027", "string")).setSize(10)
.execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
}
@Test
@ -596,7 +596,7 @@ public class SimpleSortTests extends AbstractSharedClusterTest {
.addSort("ord", SortOrder.ASC).setSize(10)
.execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().getTotalHits(), equalTo(20l));
for (int i = 0; i < 10; i++) {
@ -609,7 +609,7 @@ public class SimpleSortTests extends AbstractSharedClusterTest {
.addSort("ord", SortOrder.ASC).setSize(10)
.execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().getTotalHits(), equalTo(20l));
for (int i = 0; i < 10; i++) {
@ -623,7 +623,7 @@ public class SimpleSortTests extends AbstractSharedClusterTest {
.addSort("ord", SortOrder.ASC).setSize(10)
.execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().getTotalHits(), equalTo(20l));
for (int i = 0; i < 10; i++) {
@ -637,7 +637,7 @@ public class SimpleSortTests extends AbstractSharedClusterTest {
.addSort("ord", SortOrder.ASC).setSize(10)
.execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().getTotalHits(), equalTo(20l));
for (int i = 0; i < 10; i++) {
@ -680,7 +680,7 @@ public class SimpleSortTests extends AbstractSharedClusterTest {
.addSort("svalue", SortOrder.ASC)
.execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().getTotalHits(), equalTo(3l));
assertThat((String) searchResponse.getHits().getAt(0).field("id").value(), equalTo("2"));
@ -693,7 +693,7 @@ public class SimpleSortTests extends AbstractSharedClusterTest {
.addSort("svalue", SortOrder.ASC)
.execute().actionGet();
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().getTotalHits(), equalTo(3l));
assertThat((String) searchResponse.getHits().getAt(0).field("id").value(), equalTo("2"));
@ -778,7 +778,7 @@ public class SimpleSortTests extends AbstractSharedClusterTest {
.setQuery(matchAllQuery())
.addSort(SortBuilders.fieldSort("i_value").order(SortOrder.ASC))
.execute().actionGet();
assertThat(Arrays.toString(searchResponse.getShardFailures()), searchResponse.getFailedShards(), equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().getTotalHits(), equalTo(3l));
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("1"));
@ -790,7 +790,7 @@ public class SimpleSortTests extends AbstractSharedClusterTest {
.setQuery(matchAllQuery())
.addSort(SortBuilders.fieldSort("i_value").order(SortOrder.ASC).missing("_last"))
.execute().actionGet();
assertThat(Arrays.toString(searchResponse.getShardFailures()), searchResponse.getFailedShards(), equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().getTotalHits(), equalTo(3l));
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("1"));
@ -802,7 +802,7 @@ public class SimpleSortTests extends AbstractSharedClusterTest {
.setQuery(matchAllQuery())
.addSort(SortBuilders.fieldSort("i_value").order(SortOrder.ASC).missing("_first"))
.execute().actionGet();
assertThat(Arrays.toString(searchResponse.getShardFailures()), searchResponse.getFailedShards(), equalTo(0));
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().getTotalHits(), equalTo(3l));
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("2"));

View File

@ -45,6 +45,7 @@ import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS;
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
import static org.hamcrest.Matchers.*;
public class CompletionSuggestSearchTests extends AbstractSharedClusterTest {
@ -346,8 +347,7 @@ public class CompletionSuggestSearchTests extends AbstractSharedClusterTest {
}
private void assertSuggestions(SuggestResponse suggestResponse, boolean suggestionOrderStrict, String name, String... suggestions) {
assertThat(suggestResponse.getFailedShards(), is(0));
assertNoFailures(suggestResponse);
assertThat(suggestResponse.getSuggest().getSuggestion(name), is(notNullValue()));
Suggest.Suggestion<Suggest.Suggestion.Entry<Suggest.Suggestion.Entry.Option>> suggestion = suggestResponse.getSuggest().getSuggestion(name);