mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-04-24 23:27:25 -04:00
Use ESIntegTestCase#prepareSearch more (#101179)
The refactoring in #101175 only covered all the one-arg call sites. This PR does the rest.
This commit is contained in:
parent
1521484d11
commit
9794c6e205
102 changed files with 976 additions and 1529 deletions
|
@ -555,14 +555,12 @@ public class DateDerivativeIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPartiallyUnmapped() throws Exception {
|
public void testPartiallyUnmapped() throws Exception {
|
||||||
SearchResponse response = client().prepareSearch("idx", "idx_unmapped")
|
SearchResponse response = prepareSearch("idx", "idx_unmapped").addAggregation(
|
||||||
.addAggregation(
|
dateHistogram("histo").field("date")
|
||||||
dateHistogram("histo").field("date")
|
.calendarInterval(DateHistogramInterval.MONTH)
|
||||||
.calendarInterval(DateHistogramInterval.MONTH)
|
.minDocCount(0)
|
||||||
.minDocCount(0)
|
.subAggregation(new DerivativePipelineAggregationBuilder("deriv", "_count"))
|
||||||
.subAggregation(new DerivativePipelineAggregationBuilder("deriv", "_count"))
|
).get();
|
||||||
)
|
|
||||||
.get();
|
|
||||||
|
|
||||||
assertNoFailures(response);
|
assertNoFailures(response);
|
||||||
|
|
||||||
|
|
|
@ -158,26 +158,21 @@ public class HighlighterWithAnalyzersTests extends ESIntegTestCase {
|
||||||
)
|
)
|
||||||
.get();
|
.get();
|
||||||
refresh();
|
refresh();
|
||||||
SearchResponse search = client().prepareSearch()
|
SearchResponse search = prepareSearch().setQuery(matchPhraseQuery("body", "Test: http://www.facebook.com "))
|
||||||
.setQuery(matchPhraseQuery("body", "Test: http://www.facebook.com "))
|
|
||||||
.highlighter(new HighlightBuilder().field("body").highlighterType("fvh"))
|
.highlighter(new HighlightBuilder().field("body").highlighterType("fvh"))
|
||||||
.get();
|
.get();
|
||||||
assertHighlight(search, 0, "body", 0, startsWith("<em>Test: http://www.facebook.com</em>"));
|
assertHighlight(search, 0, "body", 0, startsWith("<em>Test: http://www.facebook.com</em>"));
|
||||||
search = client().prepareSearch()
|
search = prepareSearch().setQuery(
|
||||||
.setQuery(
|
matchPhraseQuery(
|
||||||
matchPhraseQuery(
|
"body",
|
||||||
"body",
|
"Test: http://www.facebook.com "
|
||||||
"Test: http://www.facebook.com "
|
+ "http://elasticsearch.org http://xing.com http://cnn.com "
|
||||||
+ "http://elasticsearch.org http://xing.com http://cnn.com "
|
+ "http://quora.com http://twitter.com this is a test for highlighting "
|
||||||
+ "http://quora.com http://twitter.com this is a test for highlighting "
|
+ "feature Test: http://www.facebook.com http://elasticsearch.org "
|
||||||
+ "feature Test: http://www.facebook.com http://elasticsearch.org "
|
+ "http://xing.com http://cnn.com http://quora.com http://twitter.com this "
|
||||||
+ "http://xing.com http://cnn.com http://quora.com http://twitter.com this "
|
+ "is a test for highlighting feature"
|
||||||
+ "is a test for highlighting feature"
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
.highlighter(new HighlightBuilder().field("body").highlighterType("fvh"))
|
).highlighter(new HighlightBuilder().field("body").highlighterType("fvh")).execute().actionGet();
|
||||||
.execute()
|
|
||||||
.actionGet();
|
|
||||||
assertHighlight(
|
assertHighlight(
|
||||||
search,
|
search,
|
||||||
0,
|
0,
|
||||||
|
|
|
@ -66,7 +66,7 @@ public class MoreExpressionIT extends ESIntegTestCase {
|
||||||
paramsMap.put(params[i].toString(), params[i + 1]);
|
paramsMap.put(params[i].toString(), params[i + 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
SearchRequestBuilder req = client().prepareSearch().setIndices("test");
|
SearchRequestBuilder req = prepareSearch().setIndices("test");
|
||||||
req.setQuery(QueryBuilders.matchAllQuery())
|
req.setQuery(QueryBuilders.matchAllQuery())
|
||||||
.addSort(SortBuilders.fieldSort("id").order(SortOrder.ASC).unmappedType("long"))
|
.addSort(SortBuilders.fieldSort("id").order(SortOrder.ASC).unmappedType("long"))
|
||||||
.addScriptField("foo", new Script(ScriptType.INLINE, "expression", script, paramsMap));
|
.addScriptField("foo", new Script(ScriptType.INLINE, "expression", script, paramsMap));
|
||||||
|
@ -113,7 +113,7 @@ public class MoreExpressionIT extends ESIntegTestCase {
|
||||||
ScriptScoreFunctionBuilder score = ScoreFunctionBuilders.scriptFunction(
|
ScriptScoreFunctionBuilder score = ScoreFunctionBuilders.scriptFunction(
|
||||||
new Script(ScriptType.INLINE, "expression", "1 / _score", Collections.emptyMap())
|
new Script(ScriptType.INLINE, "expression", "1 / _score", Collections.emptyMap())
|
||||||
);
|
);
|
||||||
SearchRequestBuilder req = client().prepareSearch().setIndices("test");
|
SearchRequestBuilder req = prepareSearch().setIndices("test");
|
||||||
req.setQuery(QueryBuilders.functionScoreQuery(QueryBuilders.termQuery("text", "hello"), score).boostMode(CombineFunction.REPLACE));
|
req.setQuery(QueryBuilders.functionScoreQuery(QueryBuilders.termQuery("text", "hello"), score).boostMode(CombineFunction.REPLACE));
|
||||||
req.setSearchType(SearchType.DFS_QUERY_THEN_FETCH); // make sure DF is consistent
|
req.setSearchType(SearchType.DFS_QUERY_THEN_FETCH); // make sure DF is consistent
|
||||||
SearchResponse rsp = req.get();
|
SearchResponse rsp = req.get();
|
||||||
|
@ -124,7 +124,7 @@ public class MoreExpressionIT extends ESIntegTestCase {
|
||||||
assertEquals("3", hits.getAt(1).getId());
|
assertEquals("3", hits.getAt(1).getId());
|
||||||
assertEquals("2", hits.getAt(2).getId());
|
assertEquals("2", hits.getAt(2).getId());
|
||||||
|
|
||||||
req = client().prepareSearch().setIndices("test");
|
req = prepareSearch().setIndices("test");
|
||||||
req.setQuery(QueryBuilders.functionScoreQuery(QueryBuilders.termQuery("text", "hello"), score).boostMode(CombineFunction.REPLACE));
|
req.setQuery(QueryBuilders.functionScoreQuery(QueryBuilders.termQuery("text", "hello"), score).boostMode(CombineFunction.REPLACE));
|
||||||
score = ScoreFunctionBuilders.scriptFunction(new Script(ScriptType.INLINE, "expression", "1 / _score", Collections.emptyMap()));
|
score = ScoreFunctionBuilders.scriptFunction(new Script(ScriptType.INLINE, "expression", "1 / _score", Collections.emptyMap()));
|
||||||
req.addAggregation(AggregationBuilders.max("max_score").script((score).getScript()));
|
req.addAggregation(AggregationBuilders.max("max_score").script((score).getScript()));
|
||||||
|
@ -466,7 +466,7 @@ public class MoreExpressionIT extends ESIntegTestCase {
|
||||||
client().prepareIndex("test").setId("3").setSource("x", 13, "y", 1.8)
|
client().prepareIndex("test").setId("3").setSource("x", 13, "y", 1.8)
|
||||||
);
|
);
|
||||||
|
|
||||||
SearchRequestBuilder req = client().prepareSearch().setIndices("test");
|
SearchRequestBuilder req = prepareSearch().setIndices("test");
|
||||||
req.setQuery(QueryBuilders.matchAllQuery())
|
req.setQuery(QueryBuilders.matchAllQuery())
|
||||||
.addAggregation(
|
.addAggregation(
|
||||||
AggregationBuilders.stats("int_agg")
|
AggregationBuilders.stats("int_agg")
|
||||||
|
@ -512,7 +512,7 @@ public class MoreExpressionIT extends ESIntegTestCase {
|
||||||
client().prepareIndex("test").setId("3").setSource("text", "hello")
|
client().prepareIndex("test").setId("3").setSource("text", "hello")
|
||||||
);
|
);
|
||||||
|
|
||||||
SearchRequestBuilder req = client().prepareSearch().setIndices("test");
|
SearchRequestBuilder req = prepareSearch().setIndices("test");
|
||||||
req.setQuery(QueryBuilders.matchAllQuery())
|
req.setQuery(QueryBuilders.matchAllQuery())
|
||||||
.addAggregation(
|
.addAggregation(
|
||||||
AggregationBuilders.terms("term_agg")
|
AggregationBuilders.terms("term_agg")
|
||||||
|
|
|
@ -50,12 +50,9 @@ public class StoredExpressionIT extends ESIntegTestCase {
|
||||||
assertThat(e.getCause().getMessage(), containsString("Failed to compile stored script [script1] using lang [expression]"));
|
assertThat(e.getCause().getMessage(), containsString("Failed to compile stored script [script1] using lang [expression]"));
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
client().prepareSearch()
|
prepareSearch().setSource(
|
||||||
.setSource(
|
new SearchSourceBuilder().scriptField("test1", new Script(ScriptType.STORED, null, "script1", Collections.emptyMap()))
|
||||||
new SearchSourceBuilder().scriptField("test1", new Script(ScriptType.STORED, null, "script1", Collections.emptyMap()))
|
).setIndices("test").get();
|
||||||
)
|
|
||||||
.setIndices("test")
|
|
||||||
.get();
|
|
||||||
fail("search script should have been rejected");
|
fail("search script should have been rejected");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
assertThat(e.toString(), containsString("cannot execute scripts using [field] context"));
|
assertThat(e.toString(), containsString("cannot execute scripts using [field] context"));
|
||||||
|
|
|
@ -1259,26 +1259,20 @@ public class ChildQuerySearchIT extends ParentChildTestCase {
|
||||||
indicesAdmin().prepareRefresh("test").get();
|
indicesAdmin().prepareRefresh("test").get();
|
||||||
|
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < 2; i++) {
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(
|
||||||
.setQuery(
|
boolQuery().must(matchAllQuery())
|
||||||
boolQuery().must(matchAllQuery())
|
.filter(boolQuery().must(hasChildQuery("child", matchQuery("c_field", "red"), ScoreMode.None)).must(matchAllQuery()))
|
||||||
.filter(
|
).get();
|
||||||
boolQuery().must(hasChildQuery("child", matchQuery("c_field", "red"), ScoreMode.None)).must(matchAllQuery())
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.get();
|
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(2L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(2L));
|
||||||
}
|
}
|
||||||
|
|
||||||
createIndexRequest("test", "child", "c3", "p2", "c_field", "blue").get();
|
createIndexRequest("test", "child", "c3", "p2", "c_field", "blue").get();
|
||||||
indicesAdmin().prepareRefresh("test").get();
|
indicesAdmin().prepareRefresh("test").get();
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(
|
||||||
.setQuery(
|
boolQuery().must(matchAllQuery())
|
||||||
boolQuery().must(matchAllQuery())
|
.filter(boolQuery().must(hasChildQuery("child", matchQuery("c_field", "red"), ScoreMode.None)).must(matchAllQuery()))
|
||||||
.filter(boolQuery().must(hasChildQuery("child", matchQuery("c_field", "red"), ScoreMode.None)).must(matchAllQuery()))
|
).get();
|
||||||
)
|
|
||||||
.get();
|
|
||||||
|
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
||||||
}
|
}
|
||||||
|
|
|
@ -590,13 +590,12 @@ public class InnerHitsIT extends ParentChildTestCase {
|
||||||
client().prepareIndex("index2").setId("3").setSource("key", "value").get();
|
client().prepareIndex("index2").setId("3").setSource("key", "value").get();
|
||||||
refresh();
|
refresh();
|
||||||
assertSearchHitsWithoutFailures(
|
assertSearchHitsWithoutFailures(
|
||||||
client().prepareSearch("index1", "index2")
|
prepareSearch("index1", "index2").setQuery(
|
||||||
.setQuery(
|
boolQuery().should(
|
||||||
boolQuery().should(
|
hasChildQuery("child_type", matchAllQuery(), ScoreMode.None).ignoreUnmapped(true)
|
||||||
hasChildQuery("child_type", matchAllQuery(), ScoreMode.None).ignoreUnmapped(true)
|
.innerHit(new InnerHitBuilder().setIgnoreUnmapped(true))
|
||||||
.innerHit(new InnerHitBuilder().setIgnoreUnmapped(true))
|
).should(termQuery("key", "value"))
|
||||||
).should(termQuery("key", "value"))
|
),
|
||||||
),
|
|
||||||
"1",
|
"1",
|
||||||
"3"
|
"3"
|
||||||
);
|
);
|
||||||
|
|
|
@ -98,14 +98,13 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
|
||||||
|
|
||||||
BytesReference source = BytesReference.bytes(jsonBuilder().startObject().endObject());
|
BytesReference source = BytesReference.bytes(jsonBuilder().startObject().endObject());
|
||||||
logger.info("percolating empty doc");
|
logger.info("percolating empty doc");
|
||||||
SearchResponse response = client().prepareSearch().setQuery(new PercolateQueryBuilder("query", source, XContentType.JSON)).get();
|
SearchResponse response = prepareSearch().setQuery(new PercolateQueryBuilder("query", source, XContentType.JSON)).get();
|
||||||
assertHitCount(response, 1);
|
assertHitCount(response, 1);
|
||||||
assertThat(response.getHits().getAt(0).getId(), equalTo("1"));
|
assertThat(response.getHits().getAt(0).getId(), equalTo("1"));
|
||||||
|
|
||||||
source = BytesReference.bytes(jsonBuilder().startObject().field("field1", "value").endObject());
|
source = BytesReference.bytes(jsonBuilder().startObject().field("field1", "value").endObject());
|
||||||
logger.info("percolating doc with 1 field");
|
logger.info("percolating doc with 1 field");
|
||||||
response = client().prepareSearch()
|
response = prepareSearch().setQuery(new PercolateQueryBuilder("query", source, XContentType.JSON))
|
||||||
.setQuery(new PercolateQueryBuilder("query", source, XContentType.JSON))
|
|
||||||
.addSort("id", SortOrder.ASC)
|
.addSort("id", SortOrder.ASC)
|
||||||
.get();
|
.get();
|
||||||
assertHitCount(response, 2);
|
assertHitCount(response, 2);
|
||||||
|
@ -116,8 +115,7 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
|
||||||
|
|
||||||
source = BytesReference.bytes(jsonBuilder().startObject().field("field1", "value").field("field2", "value").endObject());
|
source = BytesReference.bytes(jsonBuilder().startObject().field("field1", "value").field("field2", "value").endObject());
|
||||||
logger.info("percolating doc with 2 fields");
|
logger.info("percolating doc with 2 fields");
|
||||||
response = client().prepareSearch()
|
response = prepareSearch().setQuery(new PercolateQueryBuilder("query", source, XContentType.JSON))
|
||||||
.setQuery(new PercolateQueryBuilder("query", source, XContentType.JSON))
|
|
||||||
.addSort("id", SortOrder.ASC)
|
.addSort("id", SortOrder.ASC)
|
||||||
.get();
|
.get();
|
||||||
assertHitCount(response, 3);
|
assertHitCount(response, 3);
|
||||||
|
@ -129,19 +127,16 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
|
||||||
assertThat(response.getHits().getAt(2).getFields().get("_percolator_document_slot").getValue(), equalTo(0));
|
assertThat(response.getHits().getAt(2).getFields().get("_percolator_document_slot").getValue(), equalTo(0));
|
||||||
|
|
||||||
logger.info("percolating doc with 2 fields");
|
logger.info("percolating doc with 2 fields");
|
||||||
response = client().prepareSearch()
|
response = prepareSearch().setQuery(
|
||||||
.setQuery(
|
new PercolateQueryBuilder(
|
||||||
new PercolateQueryBuilder(
|
"query",
|
||||||
"query",
|
Arrays.asList(
|
||||||
Arrays.asList(
|
BytesReference.bytes(jsonBuilder().startObject().field("field1", "value").endObject()),
|
||||||
BytesReference.bytes(jsonBuilder().startObject().field("field1", "value").endObject()),
|
BytesReference.bytes(jsonBuilder().startObject().field("field1", "value").field("field2", "value").endObject())
|
||||||
BytesReference.bytes(jsonBuilder().startObject().field("field1", "value").field("field2", "value").endObject())
|
),
|
||||||
),
|
XContentType.JSON
|
||||||
XContentType.JSON
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
.addSort("id", SortOrder.ASC)
|
).addSort("id", SortOrder.ASC).get();
|
||||||
.get();
|
|
||||||
assertHitCount(response, 3);
|
assertHitCount(response, 3);
|
||||||
assertThat(response.getHits().getAt(0).getId(), equalTo("1"));
|
assertThat(response.getHits().getAt(0).getId(), equalTo("1"));
|
||||||
assertThat(response.getHits().getAt(0).getFields().get("_percolator_document_slot").getValues(), equalTo(Arrays.asList(0, 1)));
|
assertThat(response.getHits().getAt(0).getFields().get("_percolator_document_slot").getValues(), equalTo(Arrays.asList(0, 1)));
|
||||||
|
@ -238,44 +233,44 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
|
||||||
|
|
||||||
// Test long range:
|
// Test long range:
|
||||||
BytesReference source = BytesReference.bytes(jsonBuilder().startObject().field("field1", 12).endObject());
|
BytesReference source = BytesReference.bytes(jsonBuilder().startObject().field("field1", 12).endObject());
|
||||||
SearchResponse response = client().prepareSearch().setQuery(new PercolateQueryBuilder("query", source, XContentType.JSON)).get();
|
SearchResponse response = prepareSearch().setQuery(new PercolateQueryBuilder("query", source, XContentType.JSON)).get();
|
||||||
logger.info("response={}", response);
|
logger.info("response={}", response);
|
||||||
assertHitCount(response, 2);
|
assertHitCount(response, 2);
|
||||||
assertThat(response.getHits().getAt(0).getId(), equalTo("3"));
|
assertThat(response.getHits().getAt(0).getId(), equalTo("3"));
|
||||||
assertThat(response.getHits().getAt(1).getId(), equalTo("1"));
|
assertThat(response.getHits().getAt(1).getId(), equalTo("1"));
|
||||||
|
|
||||||
source = BytesReference.bytes(jsonBuilder().startObject().field("field1", 11).endObject());
|
source = BytesReference.bytes(jsonBuilder().startObject().field("field1", 11).endObject());
|
||||||
response = client().prepareSearch().setQuery(new PercolateQueryBuilder("query", source, XContentType.JSON)).get();
|
response = prepareSearch().setQuery(new PercolateQueryBuilder("query", source, XContentType.JSON)).get();
|
||||||
assertHitCount(response, 1);
|
assertHitCount(response, 1);
|
||||||
assertThat(response.getHits().getAt(0).getId(), equalTo("1"));
|
assertThat(response.getHits().getAt(0).getId(), equalTo("1"));
|
||||||
|
|
||||||
// Test double range:
|
// Test double range:
|
||||||
source = BytesReference.bytes(jsonBuilder().startObject().field("field2", 12).endObject());
|
source = BytesReference.bytes(jsonBuilder().startObject().field("field2", 12).endObject());
|
||||||
response = client().prepareSearch().setQuery(new PercolateQueryBuilder("query", source, XContentType.JSON)).get();
|
response = prepareSearch().setQuery(new PercolateQueryBuilder("query", source, XContentType.JSON)).get();
|
||||||
assertHitCount(response, 2);
|
assertHitCount(response, 2);
|
||||||
assertThat(response.getHits().getAt(0).getId(), equalTo("6"));
|
assertThat(response.getHits().getAt(0).getId(), equalTo("6"));
|
||||||
assertThat(response.getHits().getAt(1).getId(), equalTo("4"));
|
assertThat(response.getHits().getAt(1).getId(), equalTo("4"));
|
||||||
|
|
||||||
source = BytesReference.bytes(jsonBuilder().startObject().field("field2", 11).endObject());
|
source = BytesReference.bytes(jsonBuilder().startObject().field("field2", 11).endObject());
|
||||||
response = client().prepareSearch().setQuery(new PercolateQueryBuilder("query", source, XContentType.JSON)).get();
|
response = prepareSearch().setQuery(new PercolateQueryBuilder("query", source, XContentType.JSON)).get();
|
||||||
assertHitCount(response, 1);
|
assertHitCount(response, 1);
|
||||||
assertThat(response.getHits().getAt(0).getId(), equalTo("4"));
|
assertThat(response.getHits().getAt(0).getId(), equalTo("4"));
|
||||||
|
|
||||||
// Test IP range:
|
// Test IP range:
|
||||||
source = BytesReference.bytes(jsonBuilder().startObject().field("field3", "192.168.1.5").endObject());
|
source = BytesReference.bytes(jsonBuilder().startObject().field("field3", "192.168.1.5").endObject());
|
||||||
response = client().prepareSearch().setQuery(new PercolateQueryBuilder("query", source, XContentType.JSON)).get();
|
response = prepareSearch().setQuery(new PercolateQueryBuilder("query", source, XContentType.JSON)).get();
|
||||||
assertHitCount(response, 2);
|
assertHitCount(response, 2);
|
||||||
assertThat(response.getHits().getAt(0).getId(), equalTo("9"));
|
assertThat(response.getHits().getAt(0).getId(), equalTo("9"));
|
||||||
assertThat(response.getHits().getAt(1).getId(), equalTo("7"));
|
assertThat(response.getHits().getAt(1).getId(), equalTo("7"));
|
||||||
|
|
||||||
source = BytesReference.bytes(jsonBuilder().startObject().field("field3", "192.168.1.4").endObject());
|
source = BytesReference.bytes(jsonBuilder().startObject().field("field3", "192.168.1.4").endObject());
|
||||||
response = client().prepareSearch().setQuery(new PercolateQueryBuilder("query", source, XContentType.JSON)).get();
|
response = prepareSearch().setQuery(new PercolateQueryBuilder("query", source, XContentType.JSON)).get();
|
||||||
assertHitCount(response, 1);
|
assertHitCount(response, 1);
|
||||||
assertThat(response.getHits().getAt(0).getId(), equalTo("7"));
|
assertThat(response.getHits().getAt(0).getId(), equalTo("7"));
|
||||||
|
|
||||||
// Test date range:
|
// Test date range:
|
||||||
source = BytesReference.bytes(jsonBuilder().startObject().field("field4", "2016-05-15").endObject());
|
source = BytesReference.bytes(jsonBuilder().startObject().field("field4", "2016-05-15").endObject());
|
||||||
response = client().prepareSearch().setQuery(new PercolateQueryBuilder("query", source, XContentType.JSON)).get();
|
response = prepareSearch().setQuery(new PercolateQueryBuilder("query", source, XContentType.JSON)).get();
|
||||||
assertHitCount(response, 1);
|
assertHitCount(response, 1);
|
||||||
assertThat(response.getHits().getAt(0).getId(), equalTo("10"));
|
assertThat(response.getHits().getAt(0).getId(), equalTo("10"));
|
||||||
}
|
}
|
||||||
|
@ -325,8 +320,7 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
|
||||||
BytesReference source = BytesReference.bytes(
|
BytesReference source = BytesReference.bytes(
|
||||||
jsonBuilder().startObject().startObject("field1").field("lat", 52.20).field("lon", 4.51).endObject().endObject()
|
jsonBuilder().startObject().startObject("field1").field("lat", 52.20).field("lon", 4.51).endObject().endObject()
|
||||||
);
|
);
|
||||||
SearchResponse response = client().prepareSearch()
|
SearchResponse response = prepareSearch().setQuery(new PercolateQueryBuilder("query", source, XContentType.JSON))
|
||||||
.setQuery(new PercolateQueryBuilder("query", source, XContentType.JSON))
|
|
||||||
.addSort("id", SortOrder.ASC)
|
.addSort("id", SortOrder.ASC)
|
||||||
.get();
|
.get();
|
||||||
assertHitCount(response, 3);
|
assertHitCount(response, 3);
|
||||||
|
@ -365,15 +359,12 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
|
||||||
indicesAdmin().prepareRefresh().get();
|
indicesAdmin().prepareRefresh().get();
|
||||||
|
|
||||||
logger.info("percolating empty doc");
|
logger.info("percolating empty doc");
|
||||||
SearchResponse response = client().prepareSearch()
|
SearchResponse response = prepareSearch().setQuery(new PercolateQueryBuilder("query", "test", "1", null, null, null)).get();
|
||||||
.setQuery(new PercolateQueryBuilder("query", "test", "1", null, null, null))
|
|
||||||
.get();
|
|
||||||
assertHitCount(response, 1);
|
assertHitCount(response, 1);
|
||||||
assertThat(response.getHits().getAt(0).getId(), equalTo("1"));
|
assertThat(response.getHits().getAt(0).getId(), equalTo("1"));
|
||||||
|
|
||||||
logger.info("percolating doc with 1 field");
|
logger.info("percolating doc with 1 field");
|
||||||
response = client().prepareSearch()
|
response = prepareSearch().setQuery(new PercolateQueryBuilder("query", "test", "5", null, null, null))
|
||||||
.setQuery(new PercolateQueryBuilder("query", "test", "5", null, null, null))
|
|
||||||
.addSort("id", SortOrder.ASC)
|
.addSort("id", SortOrder.ASC)
|
||||||
.get();
|
.get();
|
||||||
assertHitCount(response, 2);
|
assertHitCount(response, 2);
|
||||||
|
@ -381,8 +372,7 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
|
||||||
assertThat(response.getHits().getAt(1).getId(), equalTo("2"));
|
assertThat(response.getHits().getAt(1).getId(), equalTo("2"));
|
||||||
|
|
||||||
logger.info("percolating doc with 2 fields");
|
logger.info("percolating doc with 2 fields");
|
||||||
response = client().prepareSearch()
|
response = prepareSearch().setQuery(new PercolateQueryBuilder("query", "test", "6", null, null, null))
|
||||||
.setQuery(new PercolateQueryBuilder("query", "test", "6", null, null, null))
|
|
||||||
.addSort("id", SortOrder.ASC)
|
.addSort("id", SortOrder.ASC)
|
||||||
.get();
|
.get();
|
||||||
assertHitCount(response, 3);
|
assertHitCount(response, 3);
|
||||||
|
@ -404,7 +394,7 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
|
||||||
|
|
||||||
logger.info("percolating empty doc with source disabled");
|
logger.info("percolating empty doc with source disabled");
|
||||||
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> {
|
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> {
|
||||||
client().prepareSearch().setQuery(new PercolateQueryBuilder("query", "test", "1", null, null, null)).get();
|
prepareSearch().setQuery(new PercolateQueryBuilder("query", "test", "1", null, null, null)).get();
|
||||||
});
|
});
|
||||||
assertThat(e.getMessage(), containsString("source disabled"));
|
assertThat(e.getMessage(), containsString("source disabled"));
|
||||||
}
|
}
|
||||||
|
@ -488,8 +478,7 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
|
||||||
.field("field2", "the quick brown fox falls down into the well")
|
.field("field2", "the quick brown fox falls down into the well")
|
||||||
.endObject()
|
.endObject()
|
||||||
);
|
);
|
||||||
SearchResponse response = client().prepareSearch()
|
SearchResponse response = prepareSearch().setQuery(new PercolateQueryBuilder("query", source, XContentType.JSON))
|
||||||
.setQuery(new PercolateQueryBuilder("query", source, XContentType.JSON))
|
|
||||||
.addSort("id", SortOrder.ASC)
|
.addSort("id", SortOrder.ASC)
|
||||||
.get();
|
.get();
|
||||||
assertHitCount(response, 3);
|
assertHitCount(response, 3);
|
||||||
|
@ -542,8 +531,7 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
|
||||||
BytesReference document = BytesReference.bytes(
|
BytesReference document = BytesReference.bytes(
|
||||||
jsonBuilder().startObject().field("field1", "The quick brown fox jumps over the lazy dog").endObject()
|
jsonBuilder().startObject().field("field1", "The quick brown fox jumps over the lazy dog").endObject()
|
||||||
);
|
);
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(new PercolateQueryBuilder("query", document, XContentType.JSON))
|
||||||
.setQuery(new PercolateQueryBuilder("query", document, XContentType.JSON))
|
|
||||||
.highlighter(new HighlightBuilder().field("field1"))
|
.highlighter(new HighlightBuilder().field("field1"))
|
||||||
.addSort("id", SortOrder.ASC)
|
.addSort("id", SortOrder.ASC)
|
||||||
.get();
|
.get();
|
||||||
|
@ -574,14 +562,10 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
|
||||||
jsonBuilder().startObject().field("field1", "The quick brown fox jumps").endObject()
|
jsonBuilder().startObject().field("field1", "The quick brown fox jumps").endObject()
|
||||||
);
|
);
|
||||||
BytesReference document2 = BytesReference.bytes(jsonBuilder().startObject().field("field1", "over the lazy dog").endObject());
|
BytesReference document2 = BytesReference.bytes(jsonBuilder().startObject().field("field1", "over the lazy dog").endObject());
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(
|
||||||
.setQuery(
|
boolQuery().should(new PercolateQueryBuilder("query", document1, XContentType.JSON).setName("query1"))
|
||||||
boolQuery().should(new PercolateQueryBuilder("query", document1, XContentType.JSON).setName("query1"))
|
.should(new PercolateQueryBuilder("query", document2, XContentType.JSON).setName("query2"))
|
||||||
.should(new PercolateQueryBuilder("query", document2, XContentType.JSON).setName("query2"))
|
).highlighter(new HighlightBuilder().field("field1")).addSort("id", SortOrder.ASC).get();
|
||||||
)
|
|
||||||
.highlighter(new HighlightBuilder().field("field1"))
|
|
||||||
.addSort("id", SortOrder.ASC)
|
|
||||||
.get();
|
|
||||||
logger.info("searchResponse={}", searchResponse);
|
logger.info("searchResponse={}", searchResponse);
|
||||||
assertHitCount(searchResponse, 5);
|
assertHitCount(searchResponse, 5);
|
||||||
|
|
||||||
|
@ -606,22 +590,18 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
|
||||||
equalTo("The quick brown <em>fox</em> jumps")
|
equalTo("The quick brown <em>fox</em> jumps")
|
||||||
);
|
);
|
||||||
|
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(
|
||||||
.setQuery(
|
new PercolateQueryBuilder(
|
||||||
new PercolateQueryBuilder(
|
"query",
|
||||||
"query",
|
Arrays.asList(
|
||||||
Arrays.asList(
|
BytesReference.bytes(jsonBuilder().startObject().field("field1", "dog").endObject()),
|
||||||
BytesReference.bytes(jsonBuilder().startObject().field("field1", "dog").endObject()),
|
BytesReference.bytes(jsonBuilder().startObject().field("field1", "fox").endObject()),
|
||||||
BytesReference.bytes(jsonBuilder().startObject().field("field1", "fox").endObject()),
|
BytesReference.bytes(jsonBuilder().startObject().field("field1", "jumps").endObject()),
|
||||||
BytesReference.bytes(jsonBuilder().startObject().field("field1", "jumps").endObject()),
|
BytesReference.bytes(jsonBuilder().startObject().field("field1", "brown fox").endObject())
|
||||||
BytesReference.bytes(jsonBuilder().startObject().field("field1", "brown fox").endObject())
|
),
|
||||||
),
|
XContentType.JSON
|
||||||
XContentType.JSON
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
.highlighter(new HighlightBuilder().field("field1"))
|
).highlighter(new HighlightBuilder().field("field1")).addSort("id", SortOrder.ASC).get();
|
||||||
.addSort("id", SortOrder.ASC)
|
|
||||||
.get();
|
|
||||||
assertHitCount(searchResponse, 5);
|
assertHitCount(searchResponse, 5);
|
||||||
assertThat(
|
assertThat(
|
||||||
searchResponse.getHits().getAt(0).getFields().get("_percolator_document_slot").getValues(),
|
searchResponse.getHits().getAt(0).getFields().get("_percolator_document_slot").getValues(),
|
||||||
|
@ -660,32 +640,28 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
|
||||||
equalTo("brown <em>fox</em>")
|
equalTo("brown <em>fox</em>")
|
||||||
);
|
);
|
||||||
|
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(
|
||||||
.setQuery(
|
boolQuery().should(
|
||||||
boolQuery().should(
|
new PercolateQueryBuilder(
|
||||||
|
"query",
|
||||||
|
Arrays.asList(
|
||||||
|
BytesReference.bytes(jsonBuilder().startObject().field("field1", "dog").endObject()),
|
||||||
|
BytesReference.bytes(jsonBuilder().startObject().field("field1", "fox").endObject())
|
||||||
|
),
|
||||||
|
XContentType.JSON
|
||||||
|
).setName("query1")
|
||||||
|
)
|
||||||
|
.should(
|
||||||
new PercolateQueryBuilder(
|
new PercolateQueryBuilder(
|
||||||
"query",
|
"query",
|
||||||
Arrays.asList(
|
Arrays.asList(
|
||||||
BytesReference.bytes(jsonBuilder().startObject().field("field1", "dog").endObject()),
|
BytesReference.bytes(jsonBuilder().startObject().field("field1", "jumps").endObject()),
|
||||||
BytesReference.bytes(jsonBuilder().startObject().field("field1", "fox").endObject())
|
BytesReference.bytes(jsonBuilder().startObject().field("field1", "brown fox").endObject())
|
||||||
),
|
),
|
||||||
XContentType.JSON
|
XContentType.JSON
|
||||||
).setName("query1")
|
).setName("query2")
|
||||||
)
|
)
|
||||||
.should(
|
).highlighter(new HighlightBuilder().field("field1")).addSort("id", SortOrder.ASC).get();
|
||||||
new PercolateQueryBuilder(
|
|
||||||
"query",
|
|
||||||
Arrays.asList(
|
|
||||||
BytesReference.bytes(jsonBuilder().startObject().field("field1", "jumps").endObject()),
|
|
||||||
BytesReference.bytes(jsonBuilder().startObject().field("field1", "brown fox").endObject())
|
|
||||||
),
|
|
||||||
XContentType.JSON
|
|
||||||
).setName("query2")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.highlighter(new HighlightBuilder().field("field1"))
|
|
||||||
.addSort("id", SortOrder.ASC)
|
|
||||||
.get();
|
|
||||||
logger.info("searchResponse={}", searchResponse);
|
logger.info("searchResponse={}", searchResponse);
|
||||||
assertHitCount(searchResponse, 5);
|
assertHitCount(searchResponse, 5);
|
||||||
assertThat(
|
assertThat(
|
||||||
|
@ -764,9 +740,9 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
|
||||||
.get();
|
.get();
|
||||||
indicesAdmin().prepareRefresh().get();
|
indicesAdmin().prepareRefresh().get();
|
||||||
|
|
||||||
SearchResponse response = client().prepareSearch()
|
SearchResponse response = prepareSearch().setQuery(
|
||||||
.setQuery(new PercolateQueryBuilder("query", new BytesArray("{\"field\" : [\"brown\", \"fox\"]}"), XContentType.JSON))
|
new PercolateQueryBuilder("query", new BytesArray("{\"field\" : [\"brown\", \"fox\"]}"), XContentType.JSON)
|
||||||
.get();
|
).get();
|
||||||
assertHitCount(response, 1);
|
assertHitCount(response, 1);
|
||||||
assertThat(response.getHits().getAt(0).getId(), equalTo("2"));
|
assertThat(response.getHits().getAt(0).getId(), equalTo("2"));
|
||||||
}
|
}
|
||||||
|
@ -846,16 +822,14 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
|
||||||
indicesAdmin().prepareRefresh().get();
|
indicesAdmin().prepareRefresh().get();
|
||||||
|
|
||||||
BytesReference source = BytesReference.bytes(jsonBuilder().startObject().field("field", "value").endObject());
|
BytesReference source = BytesReference.bytes(jsonBuilder().startObject().field("field", "value").endObject());
|
||||||
SearchResponse response = client().prepareSearch()
|
SearchResponse response = prepareSearch().setQuery(new PercolateQueryBuilder(queryFieldName, source, XContentType.JSON))
|
||||||
.setQuery(new PercolateQueryBuilder(queryFieldName, source, XContentType.JSON))
|
|
||||||
.setIndices("test1")
|
.setIndices("test1")
|
||||||
.get();
|
.get();
|
||||||
assertHitCount(response, 1);
|
assertHitCount(response, 1);
|
||||||
assertThat(response.getHits().getAt(0).getId(), equalTo("1"));
|
assertThat(response.getHits().getAt(0).getId(), equalTo("1"));
|
||||||
assertThat(response.getHits().getAt(0).getIndex(), equalTo("test1"));
|
assertThat(response.getHits().getAt(0).getIndex(), equalTo("test1"));
|
||||||
|
|
||||||
response = client().prepareSearch()
|
response = prepareSearch().setQuery(new PercolateQueryBuilder("object_field." + queryFieldName, source, XContentType.JSON))
|
||||||
.setQuery(new PercolateQueryBuilder("object_field." + queryFieldName, source, XContentType.JSON))
|
|
||||||
.setIndices("test2")
|
.setIndices("test2")
|
||||||
.get();
|
.get();
|
||||||
assertHitCount(response, 1);
|
assertHitCount(response, 1);
|
||||||
|
@ -942,10 +916,67 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
|
||||||
.get();
|
.get();
|
||||||
indicesAdmin().prepareRefresh().get();
|
indicesAdmin().prepareRefresh().get();
|
||||||
|
|
||||||
SearchResponse response = client().prepareSearch()
|
SearchResponse response = prepareSearch().setQuery(
|
||||||
.setQuery(
|
new PercolateQueryBuilder(
|
||||||
new PercolateQueryBuilder(
|
"query",
|
||||||
"query",
|
BytesReference.bytes(
|
||||||
|
XContentFactory.jsonBuilder()
|
||||||
|
.startObject()
|
||||||
|
.field("companyname", "stark")
|
||||||
|
.startArray("employee")
|
||||||
|
.startObject()
|
||||||
|
.field("name", "virginia potts")
|
||||||
|
.endObject()
|
||||||
|
.startObject()
|
||||||
|
.field("name", "tony stark")
|
||||||
|
.endObject()
|
||||||
|
.endArray()
|
||||||
|
.endObject()
|
||||||
|
),
|
||||||
|
XContentType.JSON
|
||||||
|
)
|
||||||
|
).addSort("id", SortOrder.ASC).get();
|
||||||
|
assertHitCount(response, 2);
|
||||||
|
assertThat(response.getHits().getAt(0).getId(), equalTo("q1"));
|
||||||
|
assertThat(response.getHits().getAt(1).getId(), equalTo("q3"));
|
||||||
|
|
||||||
|
response = prepareSearch().setQuery(
|
||||||
|
new PercolateQueryBuilder(
|
||||||
|
"query",
|
||||||
|
BytesReference.bytes(
|
||||||
|
XContentFactory.jsonBuilder()
|
||||||
|
.startObject()
|
||||||
|
.field("companyname", "notstark")
|
||||||
|
.startArray("employee")
|
||||||
|
.startObject()
|
||||||
|
.field("name", "virginia stark")
|
||||||
|
.endObject()
|
||||||
|
.startObject()
|
||||||
|
.field("name", "tony stark")
|
||||||
|
.endObject()
|
||||||
|
.endArray()
|
||||||
|
.endObject()
|
||||||
|
),
|
||||||
|
XContentType.JSON
|
||||||
|
)
|
||||||
|
).addSort("id", SortOrder.ASC).get();
|
||||||
|
assertHitCount(response, 1);
|
||||||
|
assertThat(response.getHits().getAt(0).getId(), equalTo("q3"));
|
||||||
|
|
||||||
|
response = prepareSearch().setQuery(
|
||||||
|
new PercolateQueryBuilder(
|
||||||
|
"query",
|
||||||
|
BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("companyname", "notstark").endObject()),
|
||||||
|
XContentType.JSON
|
||||||
|
)
|
||||||
|
).addSort("id", SortOrder.ASC).get();
|
||||||
|
assertHitCount(response, 1);
|
||||||
|
assertThat(response.getHits().getAt(0).getId(), equalTo("q3"));
|
||||||
|
|
||||||
|
response = prepareSearch().setQuery(
|
||||||
|
new PercolateQueryBuilder(
|
||||||
|
"query",
|
||||||
|
Arrays.asList(
|
||||||
BytesReference.bytes(
|
BytesReference.bytes(
|
||||||
XContentFactory.jsonBuilder()
|
XContentFactory.jsonBuilder()
|
||||||
.startObject()
|
.startObject()
|
||||||
|
@ -960,104 +991,35 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
|
||||||
.endArray()
|
.endArray()
|
||||||
.endObject()
|
.endObject()
|
||||||
),
|
),
|
||||||
XContentType.JSON
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.addSort("id", SortOrder.ASC)
|
|
||||||
.get();
|
|
||||||
assertHitCount(response, 2);
|
|
||||||
assertThat(response.getHits().getAt(0).getId(), equalTo("q1"));
|
|
||||||
assertThat(response.getHits().getAt(1).getId(), equalTo("q3"));
|
|
||||||
|
|
||||||
response = client().prepareSearch()
|
|
||||||
.setQuery(
|
|
||||||
new PercolateQueryBuilder(
|
|
||||||
"query",
|
|
||||||
BytesReference.bytes(
|
BytesReference.bytes(
|
||||||
XContentFactory.jsonBuilder()
|
XContentFactory.jsonBuilder()
|
||||||
.startObject()
|
.startObject()
|
||||||
.field("companyname", "notstark")
|
.field("companyname", "stark")
|
||||||
.startArray("employee")
|
.startArray("employee")
|
||||||
.startObject()
|
.startObject()
|
||||||
.field("name", "virginia stark")
|
.field("name", "peter parker")
|
||||||
.endObject()
|
.endObject()
|
||||||
.startObject()
|
.startObject()
|
||||||
.field("name", "tony stark")
|
.field("name", "virginia potts")
|
||||||
.endObject()
|
.endObject()
|
||||||
.endArray()
|
.endArray()
|
||||||
.endObject()
|
.endObject()
|
||||||
),
|
),
|
||||||
XContentType.JSON
|
BytesReference.bytes(
|
||||||
)
|
XContentFactory.jsonBuilder()
|
||||||
|
.startObject()
|
||||||
|
.field("companyname", "stark")
|
||||||
|
.startArray("employee")
|
||||||
|
.startObject()
|
||||||
|
.field("name", "peter parker")
|
||||||
|
.endObject()
|
||||||
|
.endArray()
|
||||||
|
.endObject()
|
||||||
|
)
|
||||||
|
),
|
||||||
|
XContentType.JSON
|
||||||
)
|
)
|
||||||
.addSort("id", SortOrder.ASC)
|
).addSort("id", SortOrder.ASC).get();
|
||||||
.get();
|
|
||||||
assertHitCount(response, 1);
|
|
||||||
assertThat(response.getHits().getAt(0).getId(), equalTo("q3"));
|
|
||||||
|
|
||||||
response = client().prepareSearch()
|
|
||||||
.setQuery(
|
|
||||||
new PercolateQueryBuilder(
|
|
||||||
"query",
|
|
||||||
BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("companyname", "notstark").endObject()),
|
|
||||||
XContentType.JSON
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.addSort("id", SortOrder.ASC)
|
|
||||||
.get();
|
|
||||||
assertHitCount(response, 1);
|
|
||||||
assertThat(response.getHits().getAt(0).getId(), equalTo("q3"));
|
|
||||||
|
|
||||||
response = client().prepareSearch()
|
|
||||||
.setQuery(
|
|
||||||
new PercolateQueryBuilder(
|
|
||||||
"query",
|
|
||||||
Arrays.asList(
|
|
||||||
BytesReference.bytes(
|
|
||||||
XContentFactory.jsonBuilder()
|
|
||||||
.startObject()
|
|
||||||
.field("companyname", "stark")
|
|
||||||
.startArray("employee")
|
|
||||||
.startObject()
|
|
||||||
.field("name", "virginia potts")
|
|
||||||
.endObject()
|
|
||||||
.startObject()
|
|
||||||
.field("name", "tony stark")
|
|
||||||
.endObject()
|
|
||||||
.endArray()
|
|
||||||
.endObject()
|
|
||||||
),
|
|
||||||
BytesReference.bytes(
|
|
||||||
XContentFactory.jsonBuilder()
|
|
||||||
.startObject()
|
|
||||||
.field("companyname", "stark")
|
|
||||||
.startArray("employee")
|
|
||||||
.startObject()
|
|
||||||
.field("name", "peter parker")
|
|
||||||
.endObject()
|
|
||||||
.startObject()
|
|
||||||
.field("name", "virginia potts")
|
|
||||||
.endObject()
|
|
||||||
.endArray()
|
|
||||||
.endObject()
|
|
||||||
),
|
|
||||||
BytesReference.bytes(
|
|
||||||
XContentFactory.jsonBuilder()
|
|
||||||
.startObject()
|
|
||||||
.field("companyname", "stark")
|
|
||||||
.startArray("employee")
|
|
||||||
.startObject()
|
|
||||||
.field("name", "peter parker")
|
|
||||||
.endObject()
|
|
||||||
.endArray()
|
|
||||||
.endObject()
|
|
||||||
)
|
|
||||||
),
|
|
||||||
XContentType.JSON
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.addSort("id", SortOrder.ASC)
|
|
||||||
.get();
|
|
||||||
assertHitCount(response, 2);
|
assertHitCount(response, 2);
|
||||||
assertThat(response.getHits().getAt(0).getId(), equalTo("q1"));
|
assertThat(response.getHits().getAt(0).getId(), equalTo("q1"));
|
||||||
assertThat(response.getHits().getAt(0).getFields().get("_percolator_document_slot").getValues(), equalTo(Arrays.asList(0, 1)));
|
assertThat(response.getHits().getAt(0).getFields().get("_percolator_document_slot").getValues(), equalTo(Arrays.asList(0, 1)));
|
||||||
|
@ -1188,9 +1150,7 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
|
||||||
|
|
||||||
// Execute with search.allow_expensive_queries = null => default value = false => success
|
// Execute with search.allow_expensive_queries = null => default value = false => success
|
||||||
BytesReference source = BytesReference.bytes(jsonBuilder().startObject().field("field1", "value").endObject());
|
BytesReference source = BytesReference.bytes(jsonBuilder().startObject().field("field1", "value").endObject());
|
||||||
SearchResponse response = client().prepareSearch()
|
SearchResponse response = prepareSearch().setQuery(new PercolateQueryBuilder("query", source, XContentType.JSON)).get();
|
||||||
.setQuery(new PercolateQueryBuilder("query", source, XContentType.JSON))
|
|
||||||
.get();
|
|
||||||
assertHitCount(response, 1);
|
assertHitCount(response, 1);
|
||||||
assertThat(response.getHits().getAt(0).getId(), equalTo("1"));
|
assertThat(response.getHits().getAt(0).getId(), equalTo("1"));
|
||||||
assertThat(response.getHits().getAt(0).getFields().get("_percolator_document_slot").getValue(), equalTo(0));
|
assertThat(response.getHits().getAt(0).getFields().get("_percolator_document_slot").getValue(), equalTo(0));
|
||||||
|
@ -1200,7 +1160,7 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
|
||||||
|
|
||||||
ElasticsearchException e = expectThrows(
|
ElasticsearchException e = expectThrows(
|
||||||
ElasticsearchException.class,
|
ElasticsearchException.class,
|
||||||
() -> client().prepareSearch().setQuery(new PercolateQueryBuilder("query", source, XContentType.JSON)).get()
|
() -> prepareSearch().setQuery(new PercolateQueryBuilder("query", source, XContentType.JSON)).get()
|
||||||
);
|
);
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"[percolate] queries cannot be executed when 'search.allow_expensive_queries' is set to false.",
|
"[percolate] queries cannot be executed when 'search.allow_expensive_queries' is set to false.",
|
||||||
|
@ -1210,7 +1170,7 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
|
||||||
// Set search.allow_expensive_queries setting to "true" ==> success
|
// Set search.allow_expensive_queries setting to "true" ==> success
|
||||||
updateClusterSettings(Settings.builder().put("search.allow_expensive_queries", true));
|
updateClusterSettings(Settings.builder().put("search.allow_expensive_queries", true));
|
||||||
|
|
||||||
response = client().prepareSearch().setQuery(new PercolateQueryBuilder("query", source, XContentType.JSON)).get();
|
response = prepareSearch().setQuery(new PercolateQueryBuilder("query", source, XContentType.JSON)).get();
|
||||||
assertHitCount(response, 1);
|
assertHitCount(response, 1);
|
||||||
assertThat(response.getHits().getAt(0).getId(), equalTo("1"));
|
assertThat(response.getHits().getAt(0).getId(), equalTo("1"));
|
||||||
assertThat(response.getHits().getAt(0).getFields().get("_percolator_document_slot").getValue(), equalTo(0));
|
assertThat(response.getHits().getAt(0).getFields().get("_percolator_document_slot").getValue(), equalTo(0));
|
||||||
|
|
|
@ -125,12 +125,12 @@ public class DeleteByQueryBasicTests extends ReindexTestCase {
|
||||||
assertHitCount(prepareSearch("test-" + i).setSize(0), remaining);
|
assertHitCount(prepareSearch("test-" + i).setSize(0), remaining);
|
||||||
}
|
}
|
||||||
|
|
||||||
assertHitCount(client().prepareSearch().setSize(0), (indices * docs) - deletions);
|
assertHitCount(prepareSearch().setSize(0), (indices * docs) - deletions);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDeleteByQueryWithMissingIndex() throws Exception {
|
public void testDeleteByQueryWithMissingIndex() throws Exception {
|
||||||
indexRandom(true, client().prepareIndex("test").setId("1").setSource("foo", "a"));
|
indexRandom(true, client().prepareIndex("test").setId("1").setSource("foo", "a"));
|
||||||
assertHitCount(client().prepareSearch().setSize(0), 1);
|
assertHitCount(prepareSearch().setSize(0), 1);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
deleteByQuery().source("missing").filter(QueryBuilders.matchAllQuery()).get();
|
deleteByQuery().source("missing").filter(QueryBuilders.matchAllQuery()).get();
|
||||||
|
@ -154,19 +154,19 @@ public class DeleteByQueryBasicTests extends ReindexTestCase {
|
||||||
indexRandom(true, true, true, builders);
|
indexRandom(true, true, true, builders);
|
||||||
|
|
||||||
logger.info("--> counting documents with no routing, should be equal to [{}]", docs);
|
logger.info("--> counting documents with no routing, should be equal to [{}]", docs);
|
||||||
assertHitCount(client().prepareSearch().setSize(0), docs);
|
assertHitCount(prepareSearch().setSize(0), docs);
|
||||||
|
|
||||||
String routing = String.valueOf(randomIntBetween(2, docs));
|
String routing = String.valueOf(randomIntBetween(2, docs));
|
||||||
|
|
||||||
logger.info("--> counting documents with routing [{}]", routing);
|
logger.info("--> counting documents with routing [{}]", routing);
|
||||||
long expected = client().prepareSearch().setSize(0).setRouting(routing).get().getHits().getTotalHits().value;
|
long expected = prepareSearch().setSize(0).setRouting(routing).get().getHits().getTotalHits().value;
|
||||||
|
|
||||||
logger.info("--> delete all documents with routing [{}] with a delete-by-query", routing);
|
logger.info("--> delete all documents with routing [{}] with a delete-by-query", routing);
|
||||||
DeleteByQueryRequestBuilder delete = deleteByQuery().source("test").filter(QueryBuilders.matchAllQuery());
|
DeleteByQueryRequestBuilder delete = deleteByQuery().source("test").filter(QueryBuilders.matchAllQuery());
|
||||||
delete.source().setRouting(routing);
|
delete.source().setRouting(routing);
|
||||||
assertThat(delete.refresh(true).get(), matcher().deleted(expected));
|
assertThat(delete.refresh(true).get(), matcher().deleted(expected));
|
||||||
|
|
||||||
assertHitCount(client().prepareSearch().setSize(0), docs - expected);
|
assertHitCount(prepareSearch().setSize(0), docs - expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDeleteByMatchQuery() throws Exception {
|
public void testDeleteByMatchQuery() throws Exception {
|
||||||
|
|
|
@ -48,12 +48,12 @@ public class DeleteIndexBlocksIT extends ESIntegTestCase {
|
||||||
refresh();
|
refresh();
|
||||||
try {
|
try {
|
||||||
updateIndexSettings(Settings.builder().put(IndexMetadata.SETTING_READ_ONLY_ALLOW_DELETE, true), "test");
|
updateIndexSettings(Settings.builder().put(IndexMetadata.SETTING_READ_ONLY_ALLOW_DELETE, true), "test");
|
||||||
assertSearchHits(client().prepareSearch(), "1");
|
assertSearchHits(prepareSearch(), "1");
|
||||||
assertBlocked(
|
assertBlocked(
|
||||||
client().prepareIndex().setIndex("test").setId("2").setSource("foo", "bar"),
|
client().prepareIndex().setIndex("test").setId("2").setSource("foo", "bar"),
|
||||||
IndexMetadata.INDEX_READ_ONLY_ALLOW_DELETE_BLOCK
|
IndexMetadata.INDEX_READ_ONLY_ALLOW_DELETE_BLOCK
|
||||||
);
|
);
|
||||||
assertSearchHits(client().prepareSearch(), "1");
|
assertSearchHits(prepareSearch(), "1");
|
||||||
assertAcked(indicesAdmin().prepareDelete("test"));
|
assertAcked(indicesAdmin().prepareDelete("test"));
|
||||||
} finally {
|
} finally {
|
||||||
Settings settings = Settings.builder().putNull(IndexMetadata.SETTING_READ_ONLY_ALLOW_DELETE).build();
|
Settings settings = Settings.builder().putNull(IndexMetadata.SETTING_READ_ONLY_ALLOW_DELETE).build();
|
||||||
|
@ -92,7 +92,7 @@ public class DeleteIndexBlocksIT extends ESIntegTestCase {
|
||||||
refresh();
|
refresh();
|
||||||
try {
|
try {
|
||||||
updateClusterSettings(Settings.builder().put(Metadata.SETTING_READ_ONLY_ALLOW_DELETE_SETTING.getKey(), true));
|
updateClusterSettings(Settings.builder().put(Metadata.SETTING_READ_ONLY_ALLOW_DELETE_SETTING.getKey(), true));
|
||||||
assertSearchHits(client().prepareSearch(), "1");
|
assertSearchHits(prepareSearch(), "1");
|
||||||
assertBlocked(
|
assertBlocked(
|
||||||
client().prepareIndex().setIndex("test").setId("2").setSource("foo", "bar"),
|
client().prepareIndex().setIndex("test").setId("2").setSource("foo", "bar"),
|
||||||
Metadata.CLUSTER_READ_ONLY_ALLOW_DELETE_BLOCK
|
Metadata.CLUSTER_READ_ONLY_ALLOW_DELETE_BLOCK
|
||||||
|
@ -101,7 +101,7 @@ public class DeleteIndexBlocksIT extends ESIntegTestCase {
|
||||||
indicesAdmin().prepareUpdateSettings("test").setSettings(Settings.builder().put("index.number_of_replicas", 2)),
|
indicesAdmin().prepareUpdateSettings("test").setSettings(Settings.builder().put("index.number_of_replicas", 2)),
|
||||||
Metadata.CLUSTER_READ_ONLY_ALLOW_DELETE_BLOCK
|
Metadata.CLUSTER_READ_ONLY_ALLOW_DELETE_BLOCK
|
||||||
);
|
);
|
||||||
assertSearchHits(client().prepareSearch(), "1");
|
assertSearchHits(prepareSearch(), "1");
|
||||||
assertAcked(indicesAdmin().prepareDelete("test"));
|
assertAcked(indicesAdmin().prepareDelete("test"));
|
||||||
} finally {
|
} finally {
|
||||||
updateClusterSettings(Settings.builder().putNull(Metadata.SETTING_READ_ONLY_ALLOW_DELETE_SETTING.getKey()));
|
updateClusterSettings(Settings.builder().putNull(Metadata.SETTING_READ_ONLY_ALLOW_DELETE_SETTING.getKey()));
|
||||||
|
|
|
@ -514,7 +514,7 @@ public class BulkWithUpdatesIT extends ESIntegTestCase {
|
||||||
|
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
assertHitCount(client().prepareSearch().setSize(0), numDocs);
|
assertHitCount(prepareSearch().setSize(0), numDocs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testFailingVersionedUpdatedOnBulk() throws Exception {
|
public void testFailingVersionedUpdatedOnBulk() throws Exception {
|
||||||
|
|
|
@ -83,7 +83,7 @@ public class PointInTimeIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
refresh("test");
|
refresh("test");
|
||||||
String pitId = openPointInTime(new String[] { "test" }, TimeValue.timeValueMinutes(2));
|
String pitId = openPointInTime(new String[] { "test" }, TimeValue.timeValueMinutes(2));
|
||||||
SearchResponse resp1 = client().prepareSearch().setPreference(null).setPointInTime(new PointInTimeBuilder(pitId)).get();
|
SearchResponse resp1 = prepareSearch().setPreference(null).setPointInTime(new PointInTimeBuilder(pitId)).get();
|
||||||
assertThat(resp1.pointInTimeId(), equalTo(pitId));
|
assertThat(resp1.pointInTimeId(), equalTo(pitId));
|
||||||
assertHitCount(resp1, numDocs);
|
assertHitCount(resp1, numDocs);
|
||||||
int deletedDocs = 0;
|
int deletedDocs = 0;
|
||||||
|
@ -101,8 +101,7 @@ public class PointInTimeIT extends ESIntegTestCase {
|
||||||
assertHitCount(resp2, numDocs - deletedDocs);
|
assertHitCount(resp2, numDocs - deletedDocs);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
SearchResponse resp3 = client().prepareSearch()
|
SearchResponse resp3 = prepareSearch().setPreference(null)
|
||||||
.setPreference(null)
|
|
||||||
.setQuery(new MatchAllQueryBuilder())
|
.setQuery(new MatchAllQueryBuilder())
|
||||||
.setPointInTime(new PointInTimeBuilder(pitId))
|
.setPointInTime(new PointInTimeBuilder(pitId))
|
||||||
.get();
|
.get();
|
||||||
|
@ -128,7 +127,7 @@ public class PointInTimeIT extends ESIntegTestCase {
|
||||||
refresh();
|
refresh();
|
||||||
String pitId = openPointInTime(new String[] { "*" }, TimeValue.timeValueMinutes(2));
|
String pitId = openPointInTime(new String[] { "*" }, TimeValue.timeValueMinutes(2));
|
||||||
try {
|
try {
|
||||||
SearchResponse resp = client().prepareSearch().setPreference(null).setPointInTime(new PointInTimeBuilder(pitId)).get();
|
SearchResponse resp = prepareSearch().setPreference(null).setPointInTime(new PointInTimeBuilder(pitId)).get();
|
||||||
assertNoFailures(resp);
|
assertNoFailures(resp);
|
||||||
assertHitCount(resp, numDocs);
|
assertHitCount(resp, numDocs);
|
||||||
assertNotNull(resp.pointInTimeId());
|
assertNotNull(resp.pointInTimeId());
|
||||||
|
@ -140,11 +139,11 @@ public class PointInTimeIT extends ESIntegTestCase {
|
||||||
client().prepareIndex(index).setId(id).setSource("value", i).get();
|
client().prepareIndex(index).setId(id).setSource("value", i).get();
|
||||||
}
|
}
|
||||||
refresh();
|
refresh();
|
||||||
resp = client().prepareSearch().get();
|
resp = prepareSearch().get();
|
||||||
assertNoFailures(resp);
|
assertNoFailures(resp);
|
||||||
assertHitCount(resp, numDocs + moreDocs);
|
assertHitCount(resp, numDocs + moreDocs);
|
||||||
|
|
||||||
resp = client().prepareSearch().setPreference(null).setPointInTime(new PointInTimeBuilder(pitId)).get();
|
resp = prepareSearch().setPreference(null).setPointInTime(new PointInTimeBuilder(pitId)).get();
|
||||||
assertNoFailures(resp);
|
assertNoFailures(resp);
|
||||||
assertHitCount(resp, numDocs);
|
assertHitCount(resp, numDocs);
|
||||||
assertNotNull(resp.pointInTimeId());
|
assertNotNull(resp.pointInTimeId());
|
||||||
|
@ -165,7 +164,7 @@ public class PointInTimeIT extends ESIntegTestCase {
|
||||||
refresh();
|
refresh();
|
||||||
String pitId = openPointInTime(new String[] { "test" }, TimeValue.timeValueMinutes(2));
|
String pitId = openPointInTime(new String[] { "test" }, TimeValue.timeValueMinutes(2));
|
||||||
try {
|
try {
|
||||||
SearchResponse resp = client().prepareSearch().setPreference(null).setPointInTime(new PointInTimeBuilder(pitId)).get();
|
SearchResponse resp = prepareSearch().setPreference(null).setPointInTime(new PointInTimeBuilder(pitId)).get();
|
||||||
assertNoFailures(resp);
|
assertNoFailures(resp);
|
||||||
assertHitCount(resp, numDocs);
|
assertHitCount(resp, numDocs);
|
||||||
assertThat(resp.pointInTimeId(), equalTo(pitId));
|
assertThat(resp.pointInTimeId(), equalTo(pitId));
|
||||||
|
@ -185,7 +184,7 @@ public class PointInTimeIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
resp = client().prepareSearch().setPreference(null).setPointInTime(new PointInTimeBuilder(pitId)).get();
|
resp = prepareSearch().setPreference(null).setPointInTime(new PointInTimeBuilder(pitId)).get();
|
||||||
assertNoFailures(resp);
|
assertNoFailures(resp);
|
||||||
assertHitCount(resp, numDocs);
|
assertHitCount(resp, numDocs);
|
||||||
assertThat(resp.pointInTimeId(), equalTo(pitId));
|
assertThat(resp.pointInTimeId(), equalTo(pitId));
|
||||||
|
@ -198,7 +197,7 @@ public class PointInTimeIT extends ESIntegTestCase {
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
assertThat(assignedNodes, everyItem(not(in(excludedNodes))));
|
assertThat(assignedNodes, everyItem(not(in(excludedNodes))));
|
||||||
}, 30, TimeUnit.SECONDS);
|
}, 30, TimeUnit.SECONDS);
|
||||||
resp = client().prepareSearch().setPreference(null).setPointInTime(new PointInTimeBuilder(pitId)).get();
|
resp = prepareSearch().setPreference(null).setPointInTime(new PointInTimeBuilder(pitId)).get();
|
||||||
assertNoFailures(resp);
|
assertNoFailures(resp);
|
||||||
assertHitCount(resp, numDocs);
|
assertHitCount(resp, numDocs);
|
||||||
assertThat(resp.pointInTimeId(), equalTo(pitId));
|
assertThat(resp.pointInTimeId(), equalTo(pitId));
|
||||||
|
@ -216,7 +215,7 @@ public class PointInTimeIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
refresh();
|
refresh();
|
||||||
String pit = openPointInTime(new String[] { "index" }, TimeValue.timeValueSeconds(5));
|
String pit = openPointInTime(new String[] { "index" }, TimeValue.timeValueSeconds(5));
|
||||||
SearchResponse resp1 = client().prepareSearch().setPreference(null).setPointInTime(new PointInTimeBuilder(pit)).get();
|
SearchResponse resp1 = prepareSearch().setPreference(null).setPointInTime(new PointInTimeBuilder(pit)).get();
|
||||||
assertNoFailures(resp1);
|
assertNoFailures(resp1);
|
||||||
assertHitCount(resp1, index1);
|
assertHitCount(resp1, index1);
|
||||||
if (rarely()) {
|
if (rarely()) {
|
||||||
|
@ -229,7 +228,7 @@ public class PointInTimeIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
SearchPhaseExecutionException e = expectThrows(
|
SearchPhaseExecutionException e = expectThrows(
|
||||||
SearchPhaseExecutionException.class,
|
SearchPhaseExecutionException.class,
|
||||||
() -> client().prepareSearch().setPreference(null).setPointInTime(new PointInTimeBuilder(pit)).get()
|
() -> prepareSearch().setPreference(null).setPointInTime(new PointInTimeBuilder(pit)).get()
|
||||||
);
|
);
|
||||||
for (ShardSearchFailure failure : e.shardFailures()) {
|
for (ShardSearchFailure failure : e.shardFailures()) {
|
||||||
assertThat(ExceptionsHelper.unwrapCause(failure.getCause()), instanceOf(SearchContextMissingException.class));
|
assertThat(ExceptionsHelper.unwrapCause(failure.getCause()), instanceOf(SearchContextMissingException.class));
|
||||||
|
@ -254,7 +253,7 @@ public class PointInTimeIT extends ESIntegTestCase {
|
||||||
refresh();
|
refresh();
|
||||||
String pit = openPointInTime(new String[] { "index-*" }, TimeValue.timeValueMinutes(2));
|
String pit = openPointInTime(new String[] { "index-*" }, TimeValue.timeValueMinutes(2));
|
||||||
try {
|
try {
|
||||||
SearchResponse resp = client().prepareSearch().setPreference(null).setPointInTime(new PointInTimeBuilder(pit)).get();
|
SearchResponse resp = prepareSearch().setPreference(null).setPointInTime(new PointInTimeBuilder(pit)).get();
|
||||||
assertNoFailures(resp);
|
assertNoFailures(resp);
|
||||||
assertHitCount(resp, index1 + index2);
|
assertHitCount(resp, index1 + index2);
|
||||||
indicesAdmin().prepareDelete("index-1").get();
|
indicesAdmin().prepareDelete("index-1").get();
|
||||||
|
@ -265,19 +264,14 @@ public class PointInTimeIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allow partial search result
|
// Allow partial search result
|
||||||
resp = client().prepareSearch()
|
resp = prepareSearch().setPreference(null).setAllowPartialSearchResults(true).setPointInTime(new PointInTimeBuilder(pit)).get();
|
||||||
.setPreference(null)
|
|
||||||
.setAllowPartialSearchResults(true)
|
|
||||||
.setPointInTime(new PointInTimeBuilder(pit))
|
|
||||||
.get();
|
|
||||||
assertFailures(resp);
|
assertFailures(resp);
|
||||||
assertHitCount(resp, index2);
|
assertHitCount(resp, index2);
|
||||||
|
|
||||||
// Do not allow partial search result
|
// Do not allow partial search result
|
||||||
expectThrows(
|
expectThrows(
|
||||||
ElasticsearchException.class,
|
ElasticsearchException.class,
|
||||||
() -> client().prepareSearch()
|
() -> prepareSearch().setPreference(null)
|
||||||
.setPreference(null)
|
|
||||||
.setAllowPartialSearchResults(false)
|
.setAllowPartialSearchResults(false)
|
||||||
.setPointInTime(new PointInTimeBuilder(pit))
|
.setPointInTime(new PointInTimeBuilder(pit))
|
||||||
.get()
|
.get()
|
||||||
|
@ -313,8 +307,7 @@ public class PointInTimeIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
client().prepareIndex("test").setId("1").setSource("created_date", "2020-01-01").get();
|
client().prepareIndex("test").setId("1").setSource("created_date", "2020-01-01").get();
|
||||||
SearchResponse resp = client().prepareSearch()
|
SearchResponse resp = prepareSearch().setQuery(new RangeQueryBuilder("created_date").gte("2020-01-02").lte("2020-01-03"))
|
||||||
.setQuery(new RangeQueryBuilder("created_date").gte("2020-01-02").lte("2020-01-03"))
|
|
||||||
.setSearchType(SearchType.QUERY_THEN_FETCH)
|
.setSearchType(SearchType.QUERY_THEN_FETCH)
|
||||||
.setPreference(null)
|
.setPreference(null)
|
||||||
.setPreFilterShardSize(randomIntBetween(2, 3))
|
.setPreFilterShardSize(randomIntBetween(2, 3))
|
||||||
|
@ -373,14 +366,13 @@ public class PointInTimeIT extends ESIntegTestCase {
|
||||||
refresh();
|
refresh();
|
||||||
String pitId = openPointInTime(new String[] { "test-*" }, TimeValue.timeValueMinutes(2));
|
String pitId = openPointInTime(new String[] { "test-*" }, TimeValue.timeValueMinutes(2));
|
||||||
try {
|
try {
|
||||||
SearchResponse resp = client().prepareSearch().setPreference(null).setPointInTime(new PointInTimeBuilder(pitId)).get();
|
SearchResponse resp = prepareSearch().setPreference(null).setPointInTime(new PointInTimeBuilder(pitId)).get();
|
||||||
assertNoFailures(resp);
|
assertNoFailures(resp);
|
||||||
assertHitCount(resp, numDocs1 + numDocs2);
|
assertHitCount(resp, numDocs1 + numDocs2);
|
||||||
assertThat(resp.pointInTimeId(), equalTo(pitId));
|
assertThat(resp.pointInTimeId(), equalTo(pitId));
|
||||||
|
|
||||||
internalCluster().restartNode(assignedNodeForIndex1);
|
internalCluster().restartNode(assignedNodeForIndex1);
|
||||||
resp = client().prepareSearch()
|
resp = prepareSearch().setPreference(null)
|
||||||
.setPreference(null)
|
|
||||||
.setAllowPartialSearchResults(true)
|
.setAllowPartialSearchResults(true)
|
||||||
.setPointInTime(new PointInTimeBuilder(pitId))
|
.setPointInTime(new PointInTimeBuilder(pitId))
|
||||||
.get();
|
.get();
|
||||||
|
@ -491,7 +483,7 @@ public class PointInTimeIT extends ESIntegTestCase {
|
||||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||||
private void assertPagination(PointInTimeBuilder pit, int expectedNumDocs, int size, SortBuilder<?>... sorts) throws Exception {
|
private void assertPagination(PointInTimeBuilder pit, int expectedNumDocs, int size, SortBuilder<?>... sorts) throws Exception {
|
||||||
Set<String> seen = new HashSet<>();
|
Set<String> seen = new HashSet<>();
|
||||||
SearchRequestBuilder builder = client().prepareSearch().setSize(size).setPointInTime(pit);
|
SearchRequestBuilder builder = prepareSearch().setSize(size).setPointInTime(pit);
|
||||||
for (SortBuilder<?> sort : sorts) {
|
for (SortBuilder<?> sort : sorts) {
|
||||||
builder.addSort(sort);
|
builder.addSort(sort);
|
||||||
}
|
}
|
||||||
|
|
|
@ -388,7 +388,7 @@ public class TransportSearchIT extends ESIntegTestCase {
|
||||||
// no exception
|
// no exception
|
||||||
prepareSearch("test1").get();
|
prepareSearch("test1").get();
|
||||||
|
|
||||||
e = expectThrows(IllegalArgumentException.class, () -> client().prepareSearch("test1", "test2").get());
|
e = expectThrows(IllegalArgumentException.class, () -> prepareSearch("test1", "test2").get());
|
||||||
assertThat(
|
assertThat(
|
||||||
e.getMessage(),
|
e.getMessage(),
|
||||||
containsString(
|
containsString(
|
||||||
|
|
|
@ -311,7 +311,7 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
terms = searchResponse.getAggregations().get("test");
|
terms = searchResponse.getAggregations().get("test");
|
||||||
assertThat(terms.getBuckets().size(), equalTo(2));
|
assertThat(terms.getBuckets().size(), equalTo(2));
|
||||||
|
|
||||||
searchResponse = client().prepareSearch("foos", "bars").setQuery(QueryBuilders.matchAllQuery()).get();
|
searchResponse = prepareSearch("foos", "bars").setQuery(QueryBuilders.matchAllQuery()).get();
|
||||||
assertHits(searchResponse.getHits(), "1", "2");
|
assertHits(searchResponse.getHits(), "1", "2");
|
||||||
|
|
||||||
logger.info("--> checking single non-filtering alias search");
|
logger.info("--> checking single non-filtering alias search");
|
||||||
|
@ -319,15 +319,15 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
assertHits(searchResponse.getHits(), "1", "2", "3", "4");
|
assertHits(searchResponse.getHits(), "1", "2", "3", "4");
|
||||||
|
|
||||||
logger.info("--> checking non-filtering alias and filtering alias search");
|
logger.info("--> checking non-filtering alias and filtering alias search");
|
||||||
searchResponse = client().prepareSearch("alias1", "foos").setQuery(QueryBuilders.matchAllQuery()).get();
|
searchResponse = prepareSearch("alias1", "foos").setQuery(QueryBuilders.matchAllQuery()).get();
|
||||||
assertHits(searchResponse.getHits(), "1", "2", "3", "4");
|
assertHits(searchResponse.getHits(), "1", "2", "3", "4");
|
||||||
|
|
||||||
logger.info("--> checking index and filtering alias search");
|
logger.info("--> checking index and filtering alias search");
|
||||||
searchResponse = client().prepareSearch("test", "foos").setQuery(QueryBuilders.matchAllQuery()).get();
|
searchResponse = prepareSearch("test", "foos").setQuery(QueryBuilders.matchAllQuery()).get();
|
||||||
assertHits(searchResponse.getHits(), "1", "2", "3", "4");
|
assertHits(searchResponse.getHits(), "1", "2", "3", "4");
|
||||||
|
|
||||||
logger.info("--> checking index and alias wildcard search");
|
logger.info("--> checking index and alias wildcard search");
|
||||||
searchResponse = client().prepareSearch("te*", "fo*").setQuery(QueryBuilders.matchAllQuery()).get();
|
searchResponse = prepareSearch("te*", "fo*").setQuery(QueryBuilders.matchAllQuery()).get();
|
||||||
assertHits(searchResponse.getHits(), "1", "2", "3", "4");
|
assertHits(searchResponse.getHits(), "1", "2", "3", "4");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -389,45 +389,34 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
);
|
);
|
||||||
|
|
||||||
logger.info("--> checking filtering alias for two indices and one complete index");
|
logger.info("--> checking filtering alias for two indices and one complete index");
|
||||||
searchResponse = client().prepareSearch("foos", "test1").setQuery(QueryBuilders.matchAllQuery()).get();
|
searchResponse = prepareSearch("foos", "test1").setQuery(QueryBuilders.matchAllQuery()).get();
|
||||||
assertHits(searchResponse.getHits(), "1", "2", "3", "4", "5");
|
assertHits(searchResponse.getHits(), "1", "2", "3", "4", "5");
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch("foos", "test1").setSize(0).setQuery(QueryBuilders.matchAllQuery()).get().getHits().getTotalHits().value,
|
prepareSearch("foos", "test1").setSize(0).setQuery(QueryBuilders.matchAllQuery()).get().getHits().getTotalHits().value,
|
||||||
equalTo(5L)
|
equalTo(5L)
|
||||||
);
|
);
|
||||||
|
|
||||||
logger.info("--> checking filtering alias for two indices and non-filtering alias for one index");
|
logger.info("--> checking filtering alias for two indices and non-filtering alias for one index");
|
||||||
searchResponse = client().prepareSearch("foos", "aliasToTest1").setQuery(QueryBuilders.matchAllQuery()).get();
|
searchResponse = prepareSearch("foos", "aliasToTest1").setQuery(QueryBuilders.matchAllQuery()).get();
|
||||||
assertHits(searchResponse.getHits(), "1", "2", "3", "4", "5");
|
assertHits(searchResponse.getHits(), "1", "2", "3", "4", "5");
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch("foos", "aliasToTest1")
|
prepareSearch("foos", "aliasToTest1").setSize(0).setQuery(QueryBuilders.matchAllQuery()).get().getHits().getTotalHits().value,
|
||||||
.setSize(0)
|
|
||||||
.setQuery(QueryBuilders.matchAllQuery())
|
|
||||||
.get()
|
|
||||||
.getHits()
|
|
||||||
.getTotalHits().value,
|
|
||||||
equalTo(5L)
|
equalTo(5L)
|
||||||
);
|
);
|
||||||
|
|
||||||
logger.info("--> checking filtering alias for two indices and non-filtering alias for both indices");
|
logger.info("--> checking filtering alias for two indices and non-filtering alias for both indices");
|
||||||
searchResponse = client().prepareSearch("foos", "aliasToTests").setQuery(QueryBuilders.matchAllQuery()).get();
|
searchResponse = prepareSearch("foos", "aliasToTests").setQuery(QueryBuilders.matchAllQuery()).get();
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(8L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(8L));
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch("foos", "aliasToTests")
|
prepareSearch("foos", "aliasToTests").setSize(0).setQuery(QueryBuilders.matchAllQuery()).get().getHits().getTotalHits().value,
|
||||||
.setSize(0)
|
|
||||||
.setQuery(QueryBuilders.matchAllQuery())
|
|
||||||
.get()
|
|
||||||
.getHits()
|
|
||||||
.getTotalHits().value,
|
|
||||||
equalTo(8L)
|
equalTo(8L)
|
||||||
);
|
);
|
||||||
|
|
||||||
logger.info("--> checking filtering alias for two indices and non-filtering alias for both indices");
|
logger.info("--> checking filtering alias for two indices and non-filtering alias for both indices");
|
||||||
searchResponse = client().prepareSearch("foos", "aliasToTests").setQuery(QueryBuilders.termQuery("name", "something")).get();
|
searchResponse = prepareSearch("foos", "aliasToTests").setQuery(QueryBuilders.termQuery("name", "something")).get();
|
||||||
assertHits(searchResponse.getHits(), "4", "8");
|
assertHits(searchResponse.getHits(), "4", "8");
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch("foos", "aliasToTests")
|
prepareSearch("foos", "aliasToTests").setSize(0)
|
||||||
.setSize(0)
|
|
||||||
.setQuery(QueryBuilders.termQuery("name", "something"))
|
.setQuery(QueryBuilders.termQuery("name", "something"))
|
||||||
.get()
|
.get()
|
||||||
.getHits()
|
.getHits()
|
||||||
|
@ -488,47 +477,31 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
logger.info("--> checking filtering alias for multiple indices");
|
logger.info("--> checking filtering alias for multiple indices");
|
||||||
SearchResponse searchResponse = client().prepareSearch("filter23", "filter13").setQuery(QueryBuilders.matchAllQuery()).get();
|
SearchResponse searchResponse = prepareSearch("filter23", "filter13").setQuery(QueryBuilders.matchAllQuery()).get();
|
||||||
assertHits(searchResponse.getHits(), "21", "31", "13", "33");
|
assertHits(searchResponse.getHits(), "21", "31", "13", "33");
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch("filter23", "filter13")
|
prepareSearch("filter23", "filter13").setSize(0).setQuery(QueryBuilders.matchAllQuery()).get().getHits().getTotalHits().value,
|
||||||
.setSize(0)
|
|
||||||
.setQuery(QueryBuilders.matchAllQuery())
|
|
||||||
.get()
|
|
||||||
.getHits()
|
|
||||||
.getTotalHits().value,
|
|
||||||
equalTo(4L)
|
equalTo(4L)
|
||||||
);
|
);
|
||||||
|
|
||||||
searchResponse = client().prepareSearch("filter23", "filter1").setQuery(QueryBuilders.matchAllQuery()).get();
|
searchResponse = prepareSearch("filter23", "filter1").setQuery(QueryBuilders.matchAllQuery()).get();
|
||||||
assertHits(searchResponse.getHits(), "21", "31", "11", "12", "13");
|
assertHits(searchResponse.getHits(), "21", "31", "11", "12", "13");
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch("filter23", "filter1")
|
prepareSearch("filter23", "filter1").setSize(0).setQuery(QueryBuilders.matchAllQuery()).get().getHits().getTotalHits().value,
|
||||||
.setSize(0)
|
|
||||||
.setQuery(QueryBuilders.matchAllQuery())
|
|
||||||
.get()
|
|
||||||
.getHits()
|
|
||||||
.getTotalHits().value,
|
|
||||||
equalTo(5L)
|
equalTo(5L)
|
||||||
);
|
);
|
||||||
|
|
||||||
searchResponse = client().prepareSearch("filter13", "filter1").setQuery(QueryBuilders.matchAllQuery()).get();
|
searchResponse = prepareSearch("filter13", "filter1").setQuery(QueryBuilders.matchAllQuery()).get();
|
||||||
assertHits(searchResponse.getHits(), "11", "12", "13", "33");
|
assertHits(searchResponse.getHits(), "11", "12", "13", "33");
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch("filter13", "filter1")
|
prepareSearch("filter13", "filter1").setSize(0).setQuery(QueryBuilders.matchAllQuery()).get().getHits().getTotalHits().value,
|
||||||
.setSize(0)
|
|
||||||
.setQuery(QueryBuilders.matchAllQuery())
|
|
||||||
.get()
|
|
||||||
.getHits()
|
|
||||||
.getTotalHits().value,
|
|
||||||
equalTo(4L)
|
equalTo(4L)
|
||||||
);
|
);
|
||||||
|
|
||||||
searchResponse = client().prepareSearch("filter13", "filter1", "filter23").setQuery(QueryBuilders.matchAllQuery()).get();
|
searchResponse = prepareSearch("filter13", "filter1", "filter23").setQuery(QueryBuilders.matchAllQuery()).get();
|
||||||
assertHits(searchResponse.getHits(), "11", "12", "13", "21", "31", "33");
|
assertHits(searchResponse.getHits(), "11", "12", "13", "21", "31", "33");
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch("filter13", "filter1", "filter23")
|
prepareSearch("filter13", "filter1", "filter23").setSize(0)
|
||||||
.setSize(0)
|
|
||||||
.setQuery(QueryBuilders.matchAllQuery())
|
.setQuery(QueryBuilders.matchAllQuery())
|
||||||
.get()
|
.get()
|
||||||
.getHits()
|
.getHits()
|
||||||
|
@ -536,11 +509,10 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
equalTo(6L)
|
equalTo(6L)
|
||||||
);
|
);
|
||||||
|
|
||||||
searchResponse = client().prepareSearch("filter23", "filter13", "test2").setQuery(QueryBuilders.matchAllQuery()).get();
|
searchResponse = prepareSearch("filter23", "filter13", "test2").setQuery(QueryBuilders.matchAllQuery()).get();
|
||||||
assertHits(searchResponse.getHits(), "21", "22", "23", "31", "13", "33");
|
assertHits(searchResponse.getHits(), "21", "22", "23", "31", "13", "33");
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch("filter23", "filter13", "test2")
|
prepareSearch("filter23", "filter13", "test2").setSize(0)
|
||||||
.setSize(0)
|
|
||||||
.setQuery(QueryBuilders.matchAllQuery())
|
.setQuery(QueryBuilders.matchAllQuery())
|
||||||
.get()
|
.get()
|
||||||
.getHits()
|
.getHits()
|
||||||
|
@ -548,11 +520,10 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
equalTo(6L)
|
equalTo(6L)
|
||||||
);
|
);
|
||||||
|
|
||||||
searchResponse = client().prepareSearch("filter23", "filter13", "test1", "test2").setQuery(QueryBuilders.matchAllQuery()).get();
|
searchResponse = prepareSearch("filter23", "filter13", "test1", "test2").setQuery(QueryBuilders.matchAllQuery()).get();
|
||||||
assertHits(searchResponse.getHits(), "11", "12", "13", "21", "22", "23", "31", "33");
|
assertHits(searchResponse.getHits(), "11", "12", "13", "21", "22", "23", "31", "33");
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch("filter23", "filter13", "test1", "test2")
|
prepareSearch("filter23", "filter13", "test1", "test2").setSize(0)
|
||||||
.setSize(0)
|
|
||||||
.setQuery(QueryBuilders.matchAllQuery())
|
.setQuery(QueryBuilders.matchAllQuery())
|
||||||
.get()
|
.get()
|
||||||
.getHits()
|
.getHits()
|
||||||
|
|
|
@ -107,13 +107,7 @@ public class MinimumMasterNodesIT extends ESIntegTestCase {
|
||||||
logger.info("--> verify we get the data back");
|
logger.info("--> verify we get the data back");
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch()
|
prepareSearch().setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value,
|
||||||
.setSize(0)
|
|
||||||
.setQuery(QueryBuilders.matchAllQuery())
|
|
||||||
.execute()
|
|
||||||
.actionGet()
|
|
||||||
.getHits()
|
|
||||||
.getTotalHits().value,
|
|
||||||
equalTo(100L)
|
equalTo(100L)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -161,7 +155,7 @@ public class MinimumMasterNodesIT extends ESIntegTestCase {
|
||||||
|
|
||||||
logger.info("--> verify we get the data back after cluster reform");
|
logger.info("--> verify we get the data back after cluster reform");
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
assertHitCount(client().prepareSearch().setSize(0).setQuery(QueryBuilders.matchAllQuery()), 100);
|
assertHitCount(prepareSearch().setSize(0).setQuery(QueryBuilders.matchAllQuery()), 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("--> clearing voting config exclusions");
|
logger.info("--> clearing voting config exclusions");
|
||||||
|
@ -208,7 +202,7 @@ public class MinimumMasterNodesIT extends ESIntegTestCase {
|
||||||
|
|
||||||
logger.info("--> verify we the data back");
|
logger.info("--> verify we the data back");
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
assertHitCount(client().prepareSearch().setSize(0).setQuery(QueryBuilders.matchAllQuery()), 100);
|
assertHitCount(prepareSearch().setSize(0).setQuery(QueryBuilders.matchAllQuery()), 100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,7 +255,7 @@ public class MinimumMasterNodesIT extends ESIntegTestCase {
|
||||||
refresh();
|
refresh();
|
||||||
logger.info("--> verify we get the data back");
|
logger.info("--> verify we get the data back");
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
assertHitCount(client().prepareSearch().setSize(0).setQuery(QueryBuilders.matchAllQuery()), 100);
|
assertHitCount(prepareSearch().setSize(0).setQuery(QueryBuilders.matchAllQuery()), 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> nonMasterNodes = new ArrayList<>(
|
List<String> nonMasterNodes = new ArrayList<>(
|
||||||
|
@ -290,7 +284,7 @@ public class MinimumMasterNodesIT extends ESIntegTestCase {
|
||||||
|
|
||||||
logger.info("--> verify we the data back");
|
logger.info("--> verify we the data back");
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
assertHitCount(client().prepareSearch().setSize(0).setQuery(QueryBuilders.matchAllQuery()), 100);
|
assertHitCount(prepareSearch().setSize(0).setQuery(QueryBuilders.matchAllQuery()), 100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,13 +52,7 @@ public class FilteringAllocationIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
indicesAdmin().prepareRefresh().execute().actionGet();
|
indicesAdmin().prepareRefresh().execute().actionGet();
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch()
|
prepareSearch().setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value,
|
||||||
.setSize(0)
|
|
||||||
.setQuery(QueryBuilders.matchAllQuery())
|
|
||||||
.execute()
|
|
||||||
.actionGet()
|
|
||||||
.getHits()
|
|
||||||
.getTotalHits().value,
|
|
||||||
equalTo(100L)
|
equalTo(100L)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -89,13 +83,7 @@ public class FilteringAllocationIT extends ESIntegTestCase {
|
||||||
|
|
||||||
indicesAdmin().prepareRefresh().execute().actionGet();
|
indicesAdmin().prepareRefresh().execute().actionGet();
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch()
|
prepareSearch().setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value,
|
||||||
.setSize(0)
|
|
||||||
.setQuery(QueryBuilders.matchAllQuery())
|
|
||||||
.execute()
|
|
||||||
.actionGet()
|
|
||||||
.getHits()
|
|
||||||
.getTotalHits().value,
|
|
||||||
equalTo(100L)
|
equalTo(100L)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -151,13 +139,7 @@ public class FilteringAllocationIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
indicesAdmin().prepareRefresh().execute().actionGet();
|
indicesAdmin().prepareRefresh().execute().actionGet();
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch()
|
prepareSearch().setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value,
|
||||||
.setSize(0)
|
|
||||||
.setQuery(QueryBuilders.matchAllQuery())
|
|
||||||
.execute()
|
|
||||||
.actionGet()
|
|
||||||
.getHits()
|
|
||||||
.getTotalHits().value,
|
|
||||||
equalTo(100L)
|
equalTo(100L)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -177,7 +177,7 @@ public class PrimaryAllocationIT extends ESIntegTestCase {
|
||||||
|
|
||||||
logger.info("--> check that the up-to-date primary shard gets promoted and that documents are available");
|
logger.info("--> check that the up-to-date primary shard gets promoted and that documents are available");
|
||||||
ensureYellow("test");
|
ensureYellow("test");
|
||||||
assertHitCount(client().prepareSearch().setSize(0).setQuery(matchAllQuery()), 2L);
|
assertHitCount(prepareSearch().setSize(0).setQuery(matchAllQuery()), 2L);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testFailedAllocationOfStalePrimaryToDataNodeWithNoData() throws Exception {
|
public void testFailedAllocationOfStalePrimaryToDataNodeWithNoData() throws Exception {
|
||||||
|
@ -475,7 +475,7 @@ public class PrimaryAllocationIT extends ESIntegTestCase {
|
||||||
internalCluster().restartRandomDataNode();
|
internalCluster().restartRandomDataNode();
|
||||||
logger.info("--> checking that index still gets allocated with only 1 shard copy being available");
|
logger.info("--> checking that index still gets allocated with only 1 shard copy being available");
|
||||||
ensureYellow("test");
|
ensureYellow("test");
|
||||||
assertHitCount(client().prepareSearch().setSize(0).setQuery(matchAllQuery()), 1L);
|
assertHitCount(prepareSearch().setSize(0).setQuery(matchAllQuery()), 1L);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -526,8 +526,7 @@ public class ShardRoutingRoleIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
String pitId = client().execute(OpenPointInTimeAction.INSTANCE, openRequest).actionGet().getPointInTimeId();
|
String pitId = client().execute(OpenPointInTimeAction.INSTANCE, openRequest).actionGet().getPointInTimeId();
|
||||||
try {
|
try {
|
||||||
final var profileResults = client().prepareSearch()
|
final var profileResults = prepareSearch().setPointInTime(new PointInTimeBuilder(pitId))
|
||||||
.setPointInTime(new PointInTimeBuilder(pitId))
|
|
||||||
.setProfile(true)
|
.setProfile(true)
|
||||||
.get()
|
.get()
|
||||||
.getProfileResults();
|
.getProfileResults();
|
||||||
|
|
|
@ -63,6 +63,6 @@ public class ClusterDisruptionCleanSettingsIT extends ESIntegTestCase {
|
||||||
|
|
||||||
IndicesStoreIntegrationIT.relocateAndBlockCompletion(logger, "test", 0, node_1, node_2);
|
IndicesStoreIntegrationIT.relocateAndBlockCompletion(logger, "test", 0, node_1, node_2);
|
||||||
// now search for the documents and see if we get a reply
|
// now search for the documents and see if we get a reply
|
||||||
assertThat(client().prepareSearch().setSize(0).get().getHits().getTotalHits().value, equalTo(100L));
|
assertThat(prepareSearch().setSize(0).get().getHits().getTotalHits().value, equalTo(100L));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -238,7 +238,7 @@ public class NodeEnvironmentIT extends ESIntegTestCase {
|
||||||
assertEquals(nodeId, clusterAdmin().prepareState().get().getState().nodes().getMasterNodeId());
|
assertEquals(nodeId, clusterAdmin().prepareState().get().getState().nodes().getMasterNodeId());
|
||||||
assertTrue(indexExists("test"));
|
assertTrue(indexExists("test"));
|
||||||
ensureYellow("test");
|
ensureYellow("test");
|
||||||
assertHitCount(client().prepareSearch().setQuery(matchAllQuery()), 1L);
|
assertHitCount(prepareSearch().setQuery(matchAllQuery()), 1L);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testFailsToStartOnDataPathsFromMultipleNodes() throws IOException {
|
public void testFailsToStartOnDataPathsFromMultipleNodes() throws IOException {
|
||||||
|
|
|
@ -283,7 +283,7 @@ public class GatewayIndexStateIT extends ESIntegTestCase {
|
||||||
|
|
||||||
logger.info("--> verify 1 doc in the index");
|
logger.info("--> verify 1 doc in the index");
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
assertHitCount(client().prepareSearch().setQuery(matchAllQuery()), 1L);
|
assertHitCount(prepareSearch().setQuery(matchAllQuery()), 1L);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("--> closing test index...");
|
logger.info("--> closing test index...");
|
||||||
|
@ -306,9 +306,9 @@ public class GatewayIndexStateIT extends ESIntegTestCase {
|
||||||
assertThat(health.isTimedOut(), equalTo(false));
|
assertThat(health.isTimedOut(), equalTo(false));
|
||||||
|
|
||||||
logger.info("--> verify 1 doc in the index");
|
logger.info("--> verify 1 doc in the index");
|
||||||
assertHitCount(client().prepareSearch().setQuery(matchAllQuery()), 1L);
|
assertHitCount(prepareSearch().setQuery(matchAllQuery()), 1L);
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
assertHitCount(client().prepareSearch().setQuery(matchAllQuery()), 1L);
|
assertHitCount(prepareSearch().setQuery(matchAllQuery()), 1L);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -548,7 +548,7 @@ public class GatewayIndexStateIT extends ESIntegTestCase {
|
||||||
assertNull(
|
assertNull(
|
||||||
state.metadata().persistentSettings().get("archived." + ShardLimitValidator.SETTING_CLUSTER_MAX_SHARDS_PER_NODE.getKey())
|
state.metadata().persistentSettings().get("archived." + ShardLimitValidator.SETTING_CLUSTER_MAX_SHARDS_PER_NODE.getKey())
|
||||||
);
|
);
|
||||||
assertHitCount(client().prepareSearch().setQuery(matchAllQuery()), 1L);
|
assertHitCount(prepareSearch().setQuery(matchAllQuery()), 1L);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testHalfDeletedIndexImport() throws Exception {
|
public void testHalfDeletedIndexImport() throws Exception {
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class QuorumGatewayIT extends ESIntegTestCase {
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
assertHitCount(client().prepareSearch().setSize(0).setQuery(matchAllQuery()), 2L);
|
assertHitCount(prepareSearch().setSize(0).setQuery(matchAllQuery()), 2L);
|
||||||
}
|
}
|
||||||
logger.info("--> restart all nodes");
|
logger.info("--> restart all nodes");
|
||||||
internalCluster().fullRestart(new RestartCallback() {
|
internalCluster().fullRestart(new RestartCallback() {
|
||||||
|
@ -90,7 +90,7 @@ public class QuorumGatewayIT extends ESIntegTestCase {
|
||||||
ensureGreen();
|
ensureGreen();
|
||||||
|
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
assertHitCount(client().prepareSearch().setSize(0).setQuery(matchAllQuery()), 3L);
|
assertHitCount(prepareSearch().setSize(0).setQuery(matchAllQuery()), 3L);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,7 +123,7 @@ public class RecoveryFromGatewayIT extends ESIntegTestCase {
|
||||||
.actionGet();
|
.actionGet();
|
||||||
|
|
||||||
refresh();
|
refresh();
|
||||||
assertHitCount(client().prepareSearch().setSize(0).setQuery(termQuery("appAccountIds", 179)), 2);
|
assertHitCount(prepareSearch().setSize(0).setQuery(termQuery("appAccountIds", 179)), 2);
|
||||||
ensureYellow("test"); // wait for primary allocations here otherwise if we have a lot of shards we might have a
|
ensureYellow("test"); // wait for primary allocations here otherwise if we have a lot of shards we might have a
|
||||||
// shard that is still in post recovery when we restart and the ensureYellow() below will timeout
|
// shard that is still in post recovery when we restart and the ensureYellow() below will timeout
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ public class RecoveryFromGatewayIT extends ESIntegTestCase {
|
||||||
primaryTerms = assertAndCapturePrimaryTerms(primaryTerms);
|
primaryTerms = assertAndCapturePrimaryTerms(primaryTerms);
|
||||||
|
|
||||||
indicesAdmin().prepareRefresh().execute().actionGet();
|
indicesAdmin().prepareRefresh().execute().actionGet();
|
||||||
assertHitCount(client().prepareSearch().setSize(0).setQuery(termQuery("appAccountIds", 179)), 2);
|
assertHitCount(prepareSearch().setSize(0).setQuery(termQuery("appAccountIds", 179)), 2);
|
||||||
|
|
||||||
internalCluster().fullRestart();
|
internalCluster().fullRestart();
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ public class RecoveryFromGatewayIT extends ESIntegTestCase {
|
||||||
primaryTerms = assertAndCapturePrimaryTerms(primaryTerms);
|
primaryTerms = assertAndCapturePrimaryTerms(primaryTerms);
|
||||||
|
|
||||||
indicesAdmin().prepareRefresh().execute().actionGet();
|
indicesAdmin().prepareRefresh().execute().actionGet();
|
||||||
assertHitCount(client().prepareSearch().setSize(0).setQuery(termQuery("appAccountIds", 179)), 2);
|
assertHitCount(prepareSearch().setSize(0).setQuery(termQuery("appAccountIds", 179)), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, long[]> assertAndCapturePrimaryTerms(Map<String, long[]> previousTerms) {
|
private Map<String, long[]> assertAndCapturePrimaryTerms(Map<String, long[]> previousTerms) {
|
||||||
|
@ -233,10 +233,10 @@ public class RecoveryFromGatewayIT extends ESIntegTestCase {
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
for (int i = 0; i <= randomInt(10); i++) {
|
for (int i = 0; i <= randomInt(10); i++) {
|
||||||
assertHitCount(client().prepareSearch().setSize(0).setQuery(matchAllQuery()), value1Docs + value2Docs);
|
assertHitCount(prepareSearch().setSize(0).setQuery(matchAllQuery()), value1Docs + value2Docs);
|
||||||
assertHitCount(client().prepareSearch().setSize(0).setQuery(termQuery("field", "value1")), value1Docs);
|
assertHitCount(prepareSearch().setSize(0).setQuery(termQuery("field", "value1")), value1Docs);
|
||||||
assertHitCount(client().prepareSearch().setSize(0).setQuery(termQuery("field", "value2")), value2Docs);
|
assertHitCount(prepareSearch().setSize(0).setQuery(termQuery("field", "value2")), value2Docs);
|
||||||
assertHitCount(client().prepareSearch().setSize(0).setQuery(termQuery("num", 179)), value1Docs);
|
assertHitCount(prepareSearch().setSize(0).setQuery(termQuery("num", 179)), value1Docs);
|
||||||
}
|
}
|
||||||
if (indexToAllShards == false) {
|
if (indexToAllShards == false) {
|
||||||
// we have to verify primaries are started for them to be restored
|
// we have to verify primaries are started for them to be restored
|
||||||
|
@ -253,10 +253,10 @@ public class RecoveryFromGatewayIT extends ESIntegTestCase {
|
||||||
primaryTerms = assertAndCapturePrimaryTerms(primaryTerms);
|
primaryTerms = assertAndCapturePrimaryTerms(primaryTerms);
|
||||||
|
|
||||||
for (int i = 0; i <= randomInt(10); i++) {
|
for (int i = 0; i <= randomInt(10); i++) {
|
||||||
assertHitCount(client().prepareSearch().setSize(0).setQuery(matchAllQuery()), value1Docs + value2Docs);
|
assertHitCount(prepareSearch().setSize(0).setQuery(matchAllQuery()), value1Docs + value2Docs);
|
||||||
assertHitCount(client().prepareSearch().setSize(0).setQuery(termQuery("field", "value1")), value1Docs);
|
assertHitCount(prepareSearch().setSize(0).setQuery(termQuery("field", "value1")), value1Docs);
|
||||||
assertHitCount(client().prepareSearch().setSize(0).setQuery(termQuery("field", "value2")), value2Docs);
|
assertHitCount(prepareSearch().setSize(0).setQuery(termQuery("field", "value2")), value2Docs);
|
||||||
assertHitCount(client().prepareSearch().setSize(0).setQuery(termQuery("num", 179)), value1Docs);
|
assertHitCount(prepareSearch().setSize(0).setQuery(termQuery("num", 179)), value1Docs);
|
||||||
}
|
}
|
||||||
|
|
||||||
internalCluster().fullRestart();
|
internalCluster().fullRestart();
|
||||||
|
@ -266,10 +266,10 @@ public class RecoveryFromGatewayIT extends ESIntegTestCase {
|
||||||
primaryTerms = assertAndCapturePrimaryTerms(primaryTerms);
|
primaryTerms = assertAndCapturePrimaryTerms(primaryTerms);
|
||||||
|
|
||||||
for (int i = 0; i <= randomInt(10); i++) {
|
for (int i = 0; i <= randomInt(10); i++) {
|
||||||
assertHitCount(client().prepareSearch().setSize(0).setQuery(matchAllQuery()), value1Docs + value2Docs);
|
assertHitCount(prepareSearch().setSize(0).setQuery(matchAllQuery()), value1Docs + value2Docs);
|
||||||
assertHitCount(client().prepareSearch().setSize(0).setQuery(termQuery("field", "value1")), value1Docs);
|
assertHitCount(prepareSearch().setSize(0).setQuery(termQuery("field", "value1")), value1Docs);
|
||||||
assertHitCount(client().prepareSearch().setSize(0).setQuery(termQuery("field", "value2")), value2Docs);
|
assertHitCount(prepareSearch().setSize(0).setQuery(termQuery("field", "value2")), value2Docs);
|
||||||
assertHitCount(client().prepareSearch().setSize(0).setQuery(termQuery("num", 179)), value1Docs);
|
assertHitCount(prepareSearch().setSize(0).setQuery(termQuery("num", 179)), value1Docs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,7 +288,7 @@ public class RecoveryFromGatewayIT extends ESIntegTestCase {
|
||||||
.actionGet();
|
.actionGet();
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
assertHitCount(client().prepareSearch().setSize(0).setQuery(matchAllQuery()), 2);
|
assertHitCount(prepareSearch().setSize(0).setQuery(matchAllQuery()), 2);
|
||||||
|
|
||||||
ensureYellow("test"); // wait for primary allocations here otherwise if we have a lot of shards we might have a
|
ensureYellow("test"); // wait for primary allocations here otherwise if we have a lot of shards we might have a
|
||||||
// shard that is still in post recovery when we restart and the ensureYellow() below will timeout
|
// shard that is still in post recovery when we restart and the ensureYellow() below will timeout
|
||||||
|
@ -302,7 +302,7 @@ public class RecoveryFromGatewayIT extends ESIntegTestCase {
|
||||||
primaryTerms = assertAndCapturePrimaryTerms(primaryTerms);
|
primaryTerms = assertAndCapturePrimaryTerms(primaryTerms);
|
||||||
|
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
assertHitCount(client().prepareSearch().setSize(0).setQuery(matchAllQuery()), 2);
|
assertHitCount(prepareSearch().setSize(0).setQuery(matchAllQuery()), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
internalCluster().fullRestart();
|
internalCluster().fullRestart();
|
||||||
|
@ -312,7 +312,7 @@ public class RecoveryFromGatewayIT extends ESIntegTestCase {
|
||||||
primaryTerms = assertAndCapturePrimaryTerms(primaryTerms);
|
primaryTerms = assertAndCapturePrimaryTerms(primaryTerms);
|
||||||
|
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
assertHitCount(client().prepareSearch().setSize(0).setQuery(matchAllQuery()), 2);
|
assertHitCount(prepareSearch().setSize(0).setQuery(matchAllQuery()), 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -337,7 +337,7 @@ public class RecoveryFromGatewayIT extends ESIntegTestCase {
|
||||||
ensureGreen();
|
ensureGreen();
|
||||||
|
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
assertHitCount(client().prepareSearch().setSize(0).setQuery(matchAllQuery()), 2);
|
assertHitCount(prepareSearch().setSize(0).setQuery(matchAllQuery()), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, long[]> primaryTerms = assertAndCapturePrimaryTerms(null);
|
Map<String, long[]> primaryTerms = assertAndCapturePrimaryTerms(null);
|
||||||
|
@ -365,7 +365,7 @@ public class RecoveryFromGatewayIT extends ESIntegTestCase {
|
||||||
primaryTerms = assertAndCapturePrimaryTerms(primaryTerms);
|
primaryTerms = assertAndCapturePrimaryTerms(primaryTerms);
|
||||||
|
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
assertHitCount(client().prepareSearch().setSize(0).setQuery(matchAllQuery()), 2);
|
assertHitCount(prepareSearch().setSize(0).setQuery(matchAllQuery()), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
client().execute(ClearVotingConfigExclusionsAction.INSTANCE, new ClearVotingConfigExclusionsRequest()).get();
|
client().execute(ClearVotingConfigExclusionsAction.INSTANCE, new ClearVotingConfigExclusionsRequest()).get();
|
||||||
|
@ -395,7 +395,7 @@ public class RecoveryFromGatewayIT extends ESIntegTestCase {
|
||||||
ensureGreen();
|
ensureGreen();
|
||||||
|
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
assertHitCount(client().prepareSearch().setSize(0).setQuery(matchAllQuery()), 2);
|
assertHitCount(prepareSearch().setSize(0).setQuery(matchAllQuery()), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
String metadataUuid = clusterAdmin().prepareState().execute().get().getState().getMetadata().clusterUUID();
|
String metadataUuid = clusterAdmin().prepareState().execute().get().getState().getMetadata().clusterUUID();
|
||||||
|
@ -418,7 +418,7 @@ public class RecoveryFromGatewayIT extends ESIntegTestCase {
|
||||||
|
|
||||||
logger.info("--> checking if documents exist, there should be 3");
|
logger.info("--> checking if documents exist, there should be 3");
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
assertHitCount(client().prepareSearch().setSize(0).setQuery(matchAllQuery()), 3);
|
assertHitCount(prepareSearch().setSize(0).setQuery(matchAllQuery()), 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("--> add some metadata and additional template");
|
logger.info("--> add some metadata and additional template");
|
||||||
|
@ -462,7 +462,7 @@ public class RecoveryFromGatewayIT extends ESIntegTestCase {
|
||||||
assertThat(clusterAdmin().prepareState().execute().get().getState().getMetadata().clusterUUID(), equalTo(metadataUuid));
|
assertThat(clusterAdmin().prepareState().execute().get().getState().getMetadata().clusterUUID(), equalTo(metadataUuid));
|
||||||
|
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
assertHitCount(client().prepareSearch().setSize(0).setQuery(matchAllQuery()), 3);
|
assertHitCount(prepareSearch().setSize(0).setQuery(matchAllQuery()), 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
ClusterState state = clusterAdmin().prepareState().execute().actionGet().getState();
|
ClusterState state = clusterAdmin().prepareState().execute().actionGet().getState();
|
||||||
|
|
|
@ -166,7 +166,7 @@ public class CorruptedFileIT extends ESIntegTestCase {
|
||||||
assertAllSuccessful(indicesAdmin().prepareFlush().setForce(true).get());
|
assertAllSuccessful(indicesAdmin().prepareFlush().setForce(true).get());
|
||||||
assertAllSuccessful(indicesAdmin().prepareFlush().setForce(true).get());
|
assertAllSuccessful(indicesAdmin().prepareFlush().setForce(true).get());
|
||||||
// we have to flush at least once here since we don't corrupt the translog
|
// we have to flush at least once here since we don't corrupt the translog
|
||||||
assertHitCount(client().prepareSearch().setSize(0), numDocs);
|
assertHitCount(prepareSearch().setSize(0), numDocs);
|
||||||
|
|
||||||
final int numShards = numShards("test");
|
final int numShards = numShards("test");
|
||||||
ShardRouting corruptedShardRouting = corruptRandomPrimaryFile();
|
ShardRouting corruptedShardRouting = corruptRandomPrimaryFile();
|
||||||
|
@ -192,7 +192,7 @@ public class CorruptedFileIT extends ESIntegTestCase {
|
||||||
assertThat(health.getStatus(), equalTo(ClusterHealthStatus.GREEN));
|
assertThat(health.getStatus(), equalTo(ClusterHealthStatus.GREEN));
|
||||||
final int numIterations = scaledRandomIntBetween(5, 20);
|
final int numIterations = scaledRandomIntBetween(5, 20);
|
||||||
for (int i = 0; i < numIterations; i++) {
|
for (int i = 0; i < numIterations; i++) {
|
||||||
assertHitCount(client().prepareSearch().setSize(numDocs), numDocs);
|
assertHitCount(prepareSearch().setSize(numDocs), numDocs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -277,7 +277,7 @@ public class CorruptedFileIT extends ESIntegTestCase {
|
||||||
assertAllSuccessful(indicesAdmin().prepareFlush().setForce(true).get());
|
assertAllSuccessful(indicesAdmin().prepareFlush().setForce(true).get());
|
||||||
assertAllSuccessful(indicesAdmin().prepareFlush().setForce(true).get());
|
assertAllSuccessful(indicesAdmin().prepareFlush().setForce(true).get());
|
||||||
// we have to flush at least once here since we don't corrupt the translog
|
// we have to flush at least once here since we don't corrupt the translog
|
||||||
assertHitCount(client().prepareSearch().setSize(0), numDocs);
|
assertHitCount(prepareSearch().setSize(0), numDocs);
|
||||||
|
|
||||||
ShardRouting shardRouting = corruptRandomPrimaryFile();
|
ShardRouting shardRouting = corruptRandomPrimaryFile();
|
||||||
/*
|
/*
|
||||||
|
@ -411,7 +411,7 @@ public class CorruptedFileIT extends ESIntegTestCase {
|
||||||
ensureGreen();
|
ensureGreen();
|
||||||
assertAllSuccessful(indicesAdmin().prepareFlush().setForce(true).execute().actionGet());
|
assertAllSuccessful(indicesAdmin().prepareFlush().setForce(true).execute().actionGet());
|
||||||
// we have to flush at least once here since we don't corrupt the translog
|
// we have to flush at least once here since we don't corrupt the translog
|
||||||
assertHitCount(client().prepareSearch().setSize(0), numDocs);
|
assertHitCount(prepareSearch().setSize(0), numDocs);
|
||||||
|
|
||||||
var source = (MockTransportService) internalCluster().getInstance(TransportService.class, primariesNode.getName());
|
var source = (MockTransportService) internalCluster().getInstance(TransportService.class, primariesNode.getName());
|
||||||
var target = internalCluster().getInstance(TransportService.class, unluckyNode.getName());
|
var target = internalCluster().getInstance(TransportService.class, unluckyNode.getName());
|
||||||
|
@ -509,7 +509,7 @@ public class CorruptedFileIT extends ESIntegTestCase {
|
||||||
|
|
||||||
final int numIterations = scaledRandomIntBetween(5, 20);
|
final int numIterations = scaledRandomIntBetween(5, 20);
|
||||||
for (int i = 0; i < numIterations; i++) {
|
for (int i = 0; i < numIterations; i++) {
|
||||||
assertHitCount(client().prepareSearch().setSize(numDocs), numDocs);
|
assertHitCount(prepareSearch().setSize(numDocs), numDocs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -550,7 +550,7 @@ public class CorruptedFileIT extends ESIntegTestCase {
|
||||||
ensureGreen();
|
ensureGreen();
|
||||||
assertAllSuccessful(indicesAdmin().prepareFlush().setForce(true).execute().actionGet());
|
assertAllSuccessful(indicesAdmin().prepareFlush().setForce(true).execute().actionGet());
|
||||||
// we have to flush at least once here since we don't corrupt the translog
|
// we have to flush at least once here since we don't corrupt the translog
|
||||||
assertHitCount(client().prepareSearch().setSize(0), numDocs);
|
assertHitCount(prepareSearch().setSize(0), numDocs);
|
||||||
|
|
||||||
ShardRouting shardRouting = corruptRandomPrimaryFile(false);
|
ShardRouting shardRouting = corruptRandomPrimaryFile(false);
|
||||||
logger.info("--> shard {} has a corrupted file", shardRouting);
|
logger.info("--> shard {} has a corrupted file", shardRouting);
|
||||||
|
@ -617,7 +617,7 @@ public class CorruptedFileIT extends ESIntegTestCase {
|
||||||
ensureGreen();
|
ensureGreen();
|
||||||
assertAllSuccessful(indicesAdmin().prepareFlush().setForce(true).execute().actionGet());
|
assertAllSuccessful(indicesAdmin().prepareFlush().setForce(true).execute().actionGet());
|
||||||
// we have to flush at least once here since we don't corrupt the translog
|
// we have to flush at least once here since we don't corrupt the translog
|
||||||
assertHitCount(client().prepareSearch().setSize(0), numDocs);
|
assertHitCount(prepareSearch().setSize(0), numDocs);
|
||||||
|
|
||||||
// disable allocations of replicas post restart (the restart will change replicas to primaries, so we have
|
// disable allocations of replicas post restart (the restart will change replicas to primaries, so we have
|
||||||
// to capture replicas post restart)
|
// to capture replicas post restart)
|
||||||
|
|
|
@ -87,7 +87,7 @@ public class DateMathIndexExpressionsIntegrationIT extends ESIntegTestCase {
|
||||||
client().prepareIndex(dateMathExp3).setId("3").setSource("{}", XContentType.JSON).get();
|
client().prepareIndex(dateMathExp3).setId("3").setSource("{}", XContentType.JSON).get();
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
SearchResponse searchResponse = dateSensitiveGet(client().prepareSearch(dateMathExp1, dateMathExp2, dateMathExp3));
|
SearchResponse searchResponse = dateSensitiveGet(prepareSearch(dateMathExp1, dateMathExp2, dateMathExp3));
|
||||||
assertHitCount(searchResponse, 3);
|
assertHitCount(searchResponse, 3);
|
||||||
assertSearchHits(searchResponse, "1", "2", "3");
|
assertSearchHits(searchResponse, "1", "2", "3");
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ public class DateMathIndexExpressionsIntegrationIT extends ESIntegTestCase {
|
||||||
client().prepareIndex(dateMathExp3).setId("3").setSource("{}", XContentType.JSON).get();
|
client().prepareIndex(dateMathExp3).setId("3").setSource("{}", XContentType.JSON).get();
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
SearchResponse searchResponse = dateSensitiveGet(client().prepareSearch(dateMathExp1, dateMathExp2, dateMathExp3));
|
SearchResponse searchResponse = dateSensitiveGet(prepareSearch(dateMathExp1, dateMathExp2, dateMathExp3));
|
||||||
assertHitCount(searchResponse, 3);
|
assertHitCount(searchResponse, 3);
|
||||||
assertSearchHits(searchResponse, "1", "2", "3");
|
assertSearchHits(searchResponse, "1", "2", "3");
|
||||||
|
|
||||||
|
|
|
@ -396,25 +396,19 @@ public class IndicesOptionsIntegrationIT extends ESIntegTestCase {
|
||||||
createIndex("test1");
|
createIndex("test1");
|
||||||
client().prepareIndex("test1").setId("1").setSource("k", "v").setRefreshPolicy(IMMEDIATE).get();
|
client().prepareIndex("test1").setId("1").setSource("k", "v").setRefreshPolicy(IMMEDIATE).get();
|
||||||
assertHitCount(prepareSearch("test2").setIndicesOptions(IndicesOptions.lenientExpandOpen()).setQuery(matchAllQuery()), 0L);
|
assertHitCount(prepareSearch("test2").setIndicesOptions(IndicesOptions.lenientExpandOpen()).setQuery(matchAllQuery()), 0L);
|
||||||
assertHitCount(
|
assertHitCount(prepareSearch("test2", "test3").setQuery(matchAllQuery()).setIndicesOptions(IndicesOptions.lenientExpandOpen()), 0L);
|
||||||
client().prepareSearch("test2", "test3").setQuery(matchAllQuery()).setIndicesOptions(IndicesOptions.lenientExpandOpen()),
|
|
||||||
0L
|
|
||||||
);
|
|
||||||
// you should still be able to run empty searches without things blowing up
|
// you should still be able to run empty searches without things blowing up
|
||||||
assertHitCount(client().prepareSearch().setIndicesOptions(IndicesOptions.lenientExpandOpen()).setQuery(matchAllQuery()), 1L);
|
assertHitCount(prepareSearch().setIndicesOptions(IndicesOptions.lenientExpandOpen()).setQuery(matchAllQuery()), 1L);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAllMissingStrict() throws Exception {
|
public void testAllMissingStrict() throws Exception {
|
||||||
createIndex("test1");
|
createIndex("test1");
|
||||||
expectThrows(IndexNotFoundException.class, () -> prepareSearch("test2").setQuery(matchAllQuery()).execute().actionGet());
|
expectThrows(IndexNotFoundException.class, () -> prepareSearch("test2").setQuery(matchAllQuery()).execute().actionGet());
|
||||||
|
|
||||||
expectThrows(
|
expectThrows(IndexNotFoundException.class, () -> prepareSearch("test2", "test3").setQuery(matchAllQuery()).execute().actionGet());
|
||||||
IndexNotFoundException.class,
|
|
||||||
() -> client().prepareSearch("test2", "test3").setQuery(matchAllQuery()).execute().actionGet()
|
|
||||||
);
|
|
||||||
|
|
||||||
// you should still be able to run empty searches without things blowing up
|
// you should still be able to run empty searches without things blowing up
|
||||||
client().prepareSearch().setQuery(matchAllQuery()).execute().actionGet();
|
prepareSearch().setQuery(matchAllQuery()).execute().actionGet();
|
||||||
}
|
}
|
||||||
|
|
||||||
// For now don't handle closed indices
|
// For now don't handle closed indices
|
||||||
|
|
|
@ -152,7 +152,7 @@ public class RandomExceptionCircuitBreakerIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < numSearches; i++) {
|
for (int i = 0; i < numSearches; i++) {
|
||||||
SearchRequestBuilder searchRequestBuilder = client().prepareSearch().setQuery(QueryBuilders.matchAllQuery());
|
SearchRequestBuilder searchRequestBuilder = prepareSearch().setQuery(QueryBuilders.matchAllQuery());
|
||||||
if (random().nextBoolean()) {
|
if (random().nextBoolean()) {
|
||||||
searchRequestBuilder.addSort("test-str", SortOrder.ASC);
|
searchRequestBuilder.addSort("test-str", SortOrder.ASC);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1076,7 +1076,7 @@ public class IndexRecoveryIT extends AbstractIndexRecoveryIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
indicesAdmin().prepareRefresh("test").get();
|
indicesAdmin().prepareRefresh("test").get();
|
||||||
assertHitCount(client().prepareSearch(), numDocs);
|
assertHitCount(prepareSearch(), numDocs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Makes sure the new master does not repeatedly fetch index metadata from recovering replicas */
|
/** Makes sure the new master does not repeatedly fetch index metadata from recovering replicas */
|
||||||
|
|
|
@ -62,7 +62,7 @@ public class UpdateNumberOfReplicasIT extends ESIntegTestCase {
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
assertHitCount(client().prepareSearch().setSize(0).setQuery(matchAllQuery()), 10L);
|
assertHitCount(prepareSearch().setSize(0).setQuery(matchAllQuery()), 10L);
|
||||||
}
|
}
|
||||||
|
|
||||||
final long settingsVersion = clusterAdmin().prepareState().get().getState().metadata().index("test").getSettingsVersion();
|
final long settingsVersion = clusterAdmin().prepareState().get().getState().metadata().index("test").getSettingsVersion();
|
||||||
|
@ -118,7 +118,7 @@ public class UpdateNumberOfReplicasIT extends ESIntegTestCase {
|
||||||
assertThat(clusterHealth.getIndices().get("test").getActiveShards(), equalTo(numShards.numPrimaries * 3));
|
assertThat(clusterHealth.getIndices().get("test").getActiveShards(), equalTo(numShards.numPrimaries * 3));
|
||||||
|
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
assertHitCount(client().prepareSearch().setSize(0).setQuery(matchAllQuery()), 10L);
|
assertHitCount(prepareSearch().setSize(0).setQuery(matchAllQuery()), 10L);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("Decreasing number of replicas from 2 to 0");
|
logger.info("Decreasing number of replicas from 2 to 0");
|
||||||
|
@ -141,7 +141,7 @@ public class UpdateNumberOfReplicasIT extends ESIntegTestCase {
|
||||||
assertThat(clusterHealth.getIndices().get("test").getActiveShards(), equalTo(numShards.numPrimaries));
|
assertThat(clusterHealth.getIndices().get("test").getActiveShards(), equalTo(numShards.numPrimaries));
|
||||||
|
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
assertHitCount(client().prepareSearch().setQuery(matchAllQuery()), 10);
|
assertHitCount(prepareSearch().setQuery(matchAllQuery()), 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
final long afterReplicaDecreaseSettingsVersion = clusterAdmin().prepareState()
|
final long afterReplicaDecreaseSettingsVersion = clusterAdmin().prepareState()
|
||||||
|
|
|
@ -296,7 +296,7 @@ public class OpenCloseIndexIT extends ESIntegTestCase {
|
||||||
// check the index still contains the records that we indexed
|
// check the index still contains the records that we indexed
|
||||||
indicesAdmin().prepareOpen("test").execute().get();
|
indicesAdmin().prepareOpen("test").execute().get();
|
||||||
ensureGreen();
|
ensureGreen();
|
||||||
SearchResponse searchResponse = client().prepareSearch().setQuery(QueryBuilders.matchQuery("test", "init")).get();
|
SearchResponse searchResponse = prepareSearch().setQuery(QueryBuilders.matchQuery("test", "init")).get();
|
||||||
assertNoFailures(searchResponse);
|
assertNoFailures(searchResponse);
|
||||||
assertHitCount(searchResponse, docs);
|
assertHitCount(searchResponse, docs);
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,8 +151,8 @@ public class IndexStatsIT extends ESIntegTestCase {
|
||||||
assertThat(indicesStats.getTotal().getFieldData().getMemorySizeInBytes(), equalTo(0L));
|
assertThat(indicesStats.getTotal().getFieldData().getMemorySizeInBytes(), equalTo(0L));
|
||||||
|
|
||||||
// sort to load it to field data...
|
// sort to load it to field data...
|
||||||
client().prepareSearch().addSort("field", SortOrder.ASC).execute().actionGet();
|
prepareSearch().addSort("field", SortOrder.ASC).execute().actionGet();
|
||||||
client().prepareSearch().addSort("field", SortOrder.ASC).execute().actionGet();
|
prepareSearch().addSort("field", SortOrder.ASC).execute().actionGet();
|
||||||
|
|
||||||
nodesStats = clusterAdmin().prepareNodesStats("data:true").setIndices(true).execute().actionGet();
|
nodesStats = clusterAdmin().prepareNodesStats("data:true").setIndices(true).execute().actionGet();
|
||||||
assertThat(
|
assertThat(
|
||||||
|
@ -167,8 +167,8 @@ public class IndexStatsIT extends ESIntegTestCase {
|
||||||
assertThat(indicesStats.getTotal().getFieldData().getMemorySizeInBytes(), greaterThan(0L));
|
assertThat(indicesStats.getTotal().getFieldData().getMemorySizeInBytes(), greaterThan(0L));
|
||||||
|
|
||||||
// sort to load it to field data...
|
// sort to load it to field data...
|
||||||
client().prepareSearch().addSort("field2", SortOrder.ASC).execute().actionGet();
|
prepareSearch().addSort("field2", SortOrder.ASC).execute().actionGet();
|
||||||
client().prepareSearch().addSort("field2", SortOrder.ASC).execute().actionGet();
|
prepareSearch().addSort("field2", SortOrder.ASC).execute().actionGet();
|
||||||
|
|
||||||
// now check the per field stats
|
// now check the per field stats
|
||||||
nodesStats = clusterAdmin().prepareNodesStats("data:true")
|
nodesStats = clusterAdmin().prepareNodesStats("data:true")
|
||||||
|
@ -272,16 +272,8 @@ public class IndexStatsIT extends ESIntegTestCase {
|
||||||
assertThat(indicesStats.getTotal().getQueryCache().getMemorySizeInBytes(), equalTo(0L));
|
assertThat(indicesStats.getTotal().getQueryCache().getMemorySizeInBytes(), equalTo(0L));
|
||||||
|
|
||||||
// sort to load it to field data and filter to load filter cache
|
// sort to load it to field data and filter to load filter cache
|
||||||
client().prepareSearch()
|
prepareSearch().setPostFilter(QueryBuilders.termQuery("field", "value1")).addSort("field", SortOrder.ASC).execute().actionGet();
|
||||||
.setPostFilter(QueryBuilders.termQuery("field", "value1"))
|
prepareSearch().setPostFilter(QueryBuilders.termQuery("field", "value2")).addSort("field", SortOrder.ASC).execute().actionGet();
|
||||||
.addSort("field", SortOrder.ASC)
|
|
||||||
.execute()
|
|
||||||
.actionGet();
|
|
||||||
client().prepareSearch()
|
|
||||||
.setPostFilter(QueryBuilders.termQuery("field", "value2"))
|
|
||||||
.addSort("field", SortOrder.ASC)
|
|
||||||
.execute()
|
|
||||||
.actionGet();
|
|
||||||
|
|
||||||
nodesStats = clusterAdmin().prepareNodesStats("data:true").setIndices(true).execute().actionGet();
|
nodesStats = clusterAdmin().prepareNodesStats("data:true").setIndices(true).execute().actionGet();
|
||||||
assertThat(
|
assertThat(
|
||||||
|
|
|
@ -95,7 +95,7 @@ public class FullRollingRestartIT extends ESIntegTestCase {
|
||||||
logger.info("--> refreshing and checking data");
|
logger.info("--> refreshing and checking data");
|
||||||
refresh();
|
refresh();
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
assertHitCount(client().prepareSearch().setSize(0).setQuery(matchAllQuery()), 2000L);
|
assertHitCount(prepareSearch().setSize(0).setQuery(matchAllQuery()), 2000L);
|
||||||
}
|
}
|
||||||
|
|
||||||
// now start shutting nodes down
|
// now start shutting nodes down
|
||||||
|
@ -124,7 +124,7 @@ public class FullRollingRestartIT extends ESIntegTestCase {
|
||||||
logger.info("--> stopped two nodes, verifying data");
|
logger.info("--> stopped two nodes, verifying data");
|
||||||
refresh();
|
refresh();
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
assertHitCount(client().prepareSearch().setSize(0).setQuery(matchAllQuery()), 2000L);
|
assertHitCount(prepareSearch().setSize(0).setQuery(matchAllQuery()), 2000L);
|
||||||
}
|
}
|
||||||
|
|
||||||
// closing the 3rd node
|
// closing the 3rd node
|
||||||
|
@ -154,7 +154,7 @@ public class FullRollingRestartIT extends ESIntegTestCase {
|
||||||
logger.info("--> one node left, verifying data");
|
logger.info("--> one node left, verifying data");
|
||||||
refresh();
|
refresh();
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
assertHitCount(client().prepareSearch().setSize(0).setQuery(matchAllQuery()), 2000L);
|
assertHitCount(prepareSearch().setSize(0).setQuery(matchAllQuery()), 2000L);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -319,8 +319,7 @@ public class RecoveryWhileUnderLoadIT extends ESIntegTestCase {
|
||||||
SearchResponse[] iterationResults = new SearchResponse[iterations];
|
SearchResponse[] iterationResults = new SearchResponse[iterations];
|
||||||
boolean error = false;
|
boolean error = false;
|
||||||
for (int i = 0; i < iterations; i++) {
|
for (int i = 0; i < iterations; i++) {
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setSize((int) numberOfDocs)
|
||||||
.setSize((int) numberOfDocs)
|
|
||||||
.setQuery(matchAllQuery())
|
.setQuery(matchAllQuery())
|
||||||
.setTrackTotalHits(true)
|
.setTrackTotalHits(true)
|
||||||
.addSort("id", SortOrder.ASC)
|
.addSort("id", SortOrder.ASC)
|
||||||
|
@ -370,11 +369,7 @@ public class RecoveryWhileUnderLoadIT extends ESIntegTestCase {
|
||||||
assertBusy(() -> {
|
assertBusy(() -> {
|
||||||
boolean errorOccurred = false;
|
boolean errorOccurred = false;
|
||||||
for (int i = 0; i < iterations; i++) {
|
for (int i = 0; i < iterations; i++) {
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setTrackTotalHits(true).setSize(0).setQuery(matchAllQuery()).get();
|
||||||
.setTrackTotalHits(true)
|
|
||||||
.setSize(0)
|
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.get();
|
|
||||||
if (searchResponse.getHits().getTotalHits().value != numberOfDocs) {
|
if (searchResponse.getHits().getTotalHits().value != numberOfDocs) {
|
||||||
errorOccurred = true;
|
errorOccurred = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -522,7 +522,7 @@ public class RelocationIT extends ESIntegTestCase {
|
||||||
final int numIters = randomIntBetween(10, 20);
|
final int numIters = randomIntBetween(10, 20);
|
||||||
for (int i = 0; i < numIters; i++) {
|
for (int i = 0; i < numIters; i++) {
|
||||||
logger.info(" --> checking iteration {}", i);
|
logger.info(" --> checking iteration {}", i);
|
||||||
assertSearchHitsWithoutFailures(client().prepareSearch().setSize(ids.size()), ids.toArray(Strings.EMPTY_ARRAY));
|
assertSearchHitsWithoutFailures(prepareSearch().setSize(ids.size()), ids.toArray(Strings.EMPTY_ARRAY));
|
||||||
}
|
}
|
||||||
stopped.set(true);
|
stopped.set(true);
|
||||||
for (Thread searchThread : searchThreads) {
|
for (Thread searchThread : searchThreads) {
|
||||||
|
|
|
@ -93,7 +93,7 @@ public class TruncatedRecoveryIT extends ESIntegTestCase {
|
||||||
indexRandom(true, builder);
|
indexRandom(true, builder);
|
||||||
for (int i = 0; i < numDocs; i++) {
|
for (int i = 0; i < numDocs; i++) {
|
||||||
String id = Integer.toString(i);
|
String id = Integer.toString(i);
|
||||||
assertHitCount(client().prepareSearch().setQuery(QueryBuilders.termQuery("the_id", id)), 1);
|
assertHitCount(prepareSearch().setQuery(QueryBuilders.termQuery("the_id", id)), 1);
|
||||||
}
|
}
|
||||||
ensureGreen();
|
ensureGreen();
|
||||||
// ensure we have flushed segments and make them a big one via optimize
|
// ensure we have flushed segments and make them a big one via optimize
|
||||||
|
@ -143,7 +143,7 @@ public class TruncatedRecoveryIT extends ESIntegTestCase {
|
||||||
ensureGreen("test");
|
ensureGreen("test");
|
||||||
for (int i = 0; i < numDocs; i++) {
|
for (int i = 0; i < numDocs; i++) {
|
||||||
String id = Integer.toString(i);
|
String id = Integer.toString(i);
|
||||||
assertHitCount(client().prepareSearch().setQuery(QueryBuilders.termQuery("the_id", id)), 1);
|
assertHitCount(prepareSearch().setQuery(QueryBuilders.termQuery("the_id", id)), 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,10 +43,7 @@ public class AliasResolveRoutingIT extends ESIntegTestCase {
|
||||||
);
|
);
|
||||||
refresh("test-*");
|
refresh("test-*");
|
||||||
assertHitCount(
|
assertHitCount(
|
||||||
client().prepareSearch()
|
prepareSearch().setIndices("alias-*").setIndicesOptions(IndicesOptions.lenientExpandOpen()).setQuery(queryStringQuery("quick")),
|
||||||
.setIndices("alias-*")
|
|
||||||
.setIndicesOptions(IndicesOptions.lenientExpandOpen())
|
|
||||||
.setQuery(queryStringQuery("quick")),
|
|
||||||
3L
|
3L
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,7 +121,7 @@ public class AliasRoutingIT extends ESIntegTestCase {
|
||||||
logger.info("--> search with no routing, should fine one");
|
logger.info("--> search with no routing, should fine one");
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch().setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value,
|
prepareSearch().setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value,
|
||||||
equalTo(1L)
|
equalTo(1L)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -129,8 +129,7 @@ public class AliasRoutingIT extends ESIntegTestCase {
|
||||||
logger.info("--> search with wrong routing, should not find");
|
logger.info("--> search with wrong routing, should not find");
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch()
|
prepareSearch().setRouting("1")
|
||||||
.setRouting("1")
|
|
||||||
.setQuery(QueryBuilders.matchAllQuery())
|
.setQuery(QueryBuilders.matchAllQuery())
|
||||||
.execute()
|
.execute()
|
||||||
.actionGet()
|
.actionGet()
|
||||||
|
@ -140,8 +139,7 @@ public class AliasRoutingIT extends ESIntegTestCase {
|
||||||
);
|
);
|
||||||
|
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch()
|
prepareSearch().setSize(0)
|
||||||
.setSize(0)
|
|
||||||
.setRouting("1")
|
.setRouting("1")
|
||||||
.setQuery(QueryBuilders.matchAllQuery())
|
.setQuery(QueryBuilders.matchAllQuery())
|
||||||
.execute()
|
.execute()
|
||||||
|
@ -171,8 +169,7 @@ public class AliasRoutingIT extends ESIntegTestCase {
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
|
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch()
|
prepareSearch().setRouting("0")
|
||||||
.setRouting("0")
|
|
||||||
.setQuery(QueryBuilders.matchAllQuery())
|
.setQuery(QueryBuilders.matchAllQuery())
|
||||||
.execute()
|
.execute()
|
||||||
.actionGet()
|
.actionGet()
|
||||||
|
@ -181,8 +178,7 @@ public class AliasRoutingIT extends ESIntegTestCase {
|
||||||
equalTo(1L)
|
equalTo(1L)
|
||||||
);
|
);
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch()
|
prepareSearch().setSize(0)
|
||||||
.setSize(0)
|
|
||||||
.setRouting("0")
|
.setRouting("0")
|
||||||
.setQuery(QueryBuilders.matchAllQuery())
|
.setQuery(QueryBuilders.matchAllQuery())
|
||||||
.execute()
|
.execute()
|
||||||
|
@ -212,17 +208,11 @@ public class AliasRoutingIT extends ESIntegTestCase {
|
||||||
logger.info("--> search with no routing, should fine two");
|
logger.info("--> search with no routing, should fine two");
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch().setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value,
|
prepareSearch().setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value,
|
||||||
equalTo(2L)
|
equalTo(2L)
|
||||||
);
|
);
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch()
|
prepareSearch().setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value,
|
||||||
.setSize(0)
|
|
||||||
.setQuery(QueryBuilders.matchAllQuery())
|
|
||||||
.execute()
|
|
||||||
.actionGet()
|
|
||||||
.getHits()
|
|
||||||
.getTotalHits().value,
|
|
||||||
equalTo(2L)
|
equalTo(2L)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -230,8 +220,7 @@ public class AliasRoutingIT extends ESIntegTestCase {
|
||||||
logger.info("--> search with 0 routing, should find one");
|
logger.info("--> search with 0 routing, should find one");
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch()
|
prepareSearch().setRouting("0")
|
||||||
.setRouting("0")
|
|
||||||
.setQuery(QueryBuilders.matchAllQuery())
|
.setQuery(QueryBuilders.matchAllQuery())
|
||||||
.execute()
|
.execute()
|
||||||
.actionGet()
|
.actionGet()
|
||||||
|
@ -240,8 +229,7 @@ public class AliasRoutingIT extends ESIntegTestCase {
|
||||||
equalTo(1L)
|
equalTo(1L)
|
||||||
);
|
);
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch()
|
prepareSearch().setSize(0)
|
||||||
.setSize(0)
|
|
||||||
.setRouting("0")
|
.setRouting("0")
|
||||||
.setQuery(QueryBuilders.matchAllQuery())
|
.setQuery(QueryBuilders.matchAllQuery())
|
||||||
.execute()
|
.execute()
|
||||||
|
@ -268,8 +256,7 @@ public class AliasRoutingIT extends ESIntegTestCase {
|
||||||
logger.info("--> search with 1 routing, should find one");
|
logger.info("--> search with 1 routing, should find one");
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch()
|
prepareSearch().setRouting("1")
|
||||||
.setRouting("1")
|
|
||||||
.setQuery(QueryBuilders.matchAllQuery())
|
.setQuery(QueryBuilders.matchAllQuery())
|
||||||
.execute()
|
.execute()
|
||||||
.actionGet()
|
.actionGet()
|
||||||
|
@ -278,8 +265,7 @@ public class AliasRoutingIT extends ESIntegTestCase {
|
||||||
equalTo(1L)
|
equalTo(1L)
|
||||||
);
|
);
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch()
|
prepareSearch().setSize(0)
|
||||||
.setSize(0)
|
|
||||||
.setRouting("1")
|
.setRouting("1")
|
||||||
.setQuery(QueryBuilders.matchAllQuery())
|
.setQuery(QueryBuilders.matchAllQuery())
|
||||||
.execute()
|
.execute()
|
||||||
|
@ -306,8 +292,7 @@ public class AliasRoutingIT extends ESIntegTestCase {
|
||||||
logger.info("--> search with 0,1 indexRoutings , should find two");
|
logger.info("--> search with 0,1 indexRoutings , should find two");
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch()
|
prepareSearch().setRouting("0", "1")
|
||||||
.setRouting("0", "1")
|
|
||||||
.setQuery(QueryBuilders.matchAllQuery())
|
.setQuery(QueryBuilders.matchAllQuery())
|
||||||
.execute()
|
.execute()
|
||||||
.actionGet()
|
.actionGet()
|
||||||
|
@ -316,8 +301,7 @@ public class AliasRoutingIT extends ESIntegTestCase {
|
||||||
equalTo(2L)
|
equalTo(2L)
|
||||||
);
|
);
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch()
|
prepareSearch().setSize(0)
|
||||||
.setSize(0)
|
|
||||||
.setRouting("0", "1")
|
.setRouting("0", "1")
|
||||||
.setQuery(QueryBuilders.matchAllQuery())
|
.setQuery(QueryBuilders.matchAllQuery())
|
||||||
.execute()
|
.execute()
|
||||||
|
@ -344,8 +328,7 @@ public class AliasRoutingIT extends ESIntegTestCase {
|
||||||
logger.info("--> search with two routing aliases , should find two");
|
logger.info("--> search with two routing aliases , should find two");
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch("alias0", "alias1")
|
prepareSearch("alias0", "alias1").setQuery(QueryBuilders.matchAllQuery())
|
||||||
.setQuery(QueryBuilders.matchAllQuery())
|
|
||||||
.execute()
|
.execute()
|
||||||
.actionGet()
|
.actionGet()
|
||||||
.getHits()
|
.getHits()
|
||||||
|
@ -353,8 +336,7 @@ public class AliasRoutingIT extends ESIntegTestCase {
|
||||||
equalTo(2L)
|
equalTo(2L)
|
||||||
);
|
);
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch("alias0", "alias1")
|
prepareSearch("alias0", "alias1").setSize(0)
|
||||||
.setSize(0)
|
|
||||||
.setQuery(QueryBuilders.matchAllQuery())
|
.setQuery(QueryBuilders.matchAllQuery())
|
||||||
.execute()
|
.execute()
|
||||||
.actionGet()
|
.actionGet()
|
||||||
|
@ -367,8 +349,7 @@ public class AliasRoutingIT extends ESIntegTestCase {
|
||||||
logger.info("--> search with alias0, alias1 and alias01, should find two");
|
logger.info("--> search with alias0, alias1 and alias01, should find two");
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch("alias0", "alias1", "alias01")
|
prepareSearch("alias0", "alias1", "alias01").setQuery(QueryBuilders.matchAllQuery())
|
||||||
.setQuery(QueryBuilders.matchAllQuery())
|
|
||||||
.execute()
|
.execute()
|
||||||
.actionGet()
|
.actionGet()
|
||||||
.getHits()
|
.getHits()
|
||||||
|
@ -376,8 +357,7 @@ public class AliasRoutingIT extends ESIntegTestCase {
|
||||||
equalTo(2L)
|
equalTo(2L)
|
||||||
);
|
);
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch("alias0", "alias1", "alias01")
|
prepareSearch("alias0", "alias1", "alias01").setSize(0)
|
||||||
.setSize(0)
|
|
||||||
.setQuery(QueryBuilders.matchAllQuery())
|
.setQuery(QueryBuilders.matchAllQuery())
|
||||||
.execute()
|
.execute()
|
||||||
.actionGet()
|
.actionGet()
|
||||||
|
@ -390,8 +370,7 @@ public class AliasRoutingIT extends ESIntegTestCase {
|
||||||
logger.info("--> search with test, alias0 and alias1, should find two");
|
logger.info("--> search with test, alias0 and alias1, should find two");
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch("test", "alias0", "alias1")
|
prepareSearch("test", "alias0", "alias1").setQuery(QueryBuilders.matchAllQuery())
|
||||||
.setQuery(QueryBuilders.matchAllQuery())
|
|
||||||
.execute()
|
.execute()
|
||||||
.actionGet()
|
.actionGet()
|
||||||
.getHits()
|
.getHits()
|
||||||
|
@ -399,8 +378,7 @@ public class AliasRoutingIT extends ESIntegTestCase {
|
||||||
equalTo(2L)
|
equalTo(2L)
|
||||||
);
|
);
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch("test", "alias0", "alias1")
|
prepareSearch("test", "alias0", "alias1").setSize(0)
|
||||||
.setSize(0)
|
|
||||||
.setQuery(QueryBuilders.matchAllQuery())
|
.setQuery(QueryBuilders.matchAllQuery())
|
||||||
.execute()
|
.execute()
|
||||||
.actionGet()
|
.actionGet()
|
||||||
|
@ -458,8 +436,7 @@ public class AliasRoutingIT extends ESIntegTestCase {
|
||||||
logger.info("--> search with alias-a1,alias-b0, should not find");
|
logger.info("--> search with alias-a1,alias-b0, should not find");
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch("alias-a1", "alias-b0")
|
prepareSearch("alias-a1", "alias-b0").setQuery(QueryBuilders.matchAllQuery())
|
||||||
.setQuery(QueryBuilders.matchAllQuery())
|
|
||||||
.execute()
|
.execute()
|
||||||
.actionGet()
|
.actionGet()
|
||||||
.getHits()
|
.getHits()
|
||||||
|
@ -467,8 +444,7 @@ public class AliasRoutingIT extends ESIntegTestCase {
|
||||||
equalTo(0L)
|
equalTo(0L)
|
||||||
);
|
);
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch("alias-a1", "alias-b0")
|
prepareSearch("alias-a1", "alias-b0").setSize(0)
|
||||||
.setSize(0)
|
|
||||||
.setQuery(QueryBuilders.matchAllQuery())
|
.setQuery(QueryBuilders.matchAllQuery())
|
||||||
.execute()
|
.execute()
|
||||||
.actionGet()
|
.actionGet()
|
||||||
|
@ -498,8 +474,7 @@ public class AliasRoutingIT extends ESIntegTestCase {
|
||||||
logger.info("--> search with alias-a0,alias-b1 should find two");
|
logger.info("--> search with alias-a0,alias-b1 should find two");
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch("alias-a0", "alias-b1")
|
prepareSearch("alias-a0", "alias-b1").setQuery(QueryBuilders.matchAllQuery())
|
||||||
.setQuery(QueryBuilders.matchAllQuery())
|
|
||||||
.execute()
|
.execute()
|
||||||
.actionGet()
|
.actionGet()
|
||||||
.getHits()
|
.getHits()
|
||||||
|
@ -507,8 +482,7 @@ public class AliasRoutingIT extends ESIntegTestCase {
|
||||||
equalTo(2L)
|
equalTo(2L)
|
||||||
);
|
);
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch("alias-a0", "alias-b1")
|
prepareSearch("alias-a0", "alias-b1").setSize(0)
|
||||||
.setSize(0)
|
|
||||||
.setQuery(QueryBuilders.matchAllQuery())
|
.setQuery(QueryBuilders.matchAllQuery())
|
||||||
.execute()
|
.execute()
|
||||||
.actionGet()
|
.actionGet()
|
||||||
|
|
|
@ -145,8 +145,7 @@ public class PartitionedRoutingIT extends ESIntegTestCase {
|
||||||
String routing = routingEntry.getKey();
|
String routing = routingEntry.getKey();
|
||||||
int expectedDocuments = routingEntry.getValue().size();
|
int expectedDocuments = routingEntry.getValue().size();
|
||||||
|
|
||||||
SearchResponse response = client().prepareSearch()
|
SearchResponse response = prepareSearch().setQuery(QueryBuilders.termQuery("_routing", routing))
|
||||||
.setQuery(QueryBuilders.termQuery("_routing", routing))
|
|
||||||
.setRouting(routing)
|
.setRouting(routing)
|
||||||
.setIndices(index)
|
.setIndices(index)
|
||||||
.setSize(100)
|
.setSize(100)
|
||||||
|
@ -183,8 +182,7 @@ public class PartitionedRoutingIT extends ESIntegTestCase {
|
||||||
String routing = routingEntry.getKey();
|
String routing = routingEntry.getKey();
|
||||||
int expectedDocuments = routingEntry.getValue().size();
|
int expectedDocuments = routingEntry.getValue().size();
|
||||||
|
|
||||||
SearchResponse response = client().prepareSearch()
|
SearchResponse response = prepareSearch().setQuery(QueryBuilders.termQuery("_routing", routing))
|
||||||
.setQuery(QueryBuilders.termQuery("_routing", routing))
|
|
||||||
.setIndices(index)
|
.setIndices(index)
|
||||||
.setSize(100)
|
.setSize(100)
|
||||||
.execute()
|
.execute()
|
||||||
|
|
|
@ -138,7 +138,7 @@ public class SimpleRoutingIT extends ESIntegTestCase {
|
||||||
logger.info("--> search with no routing, should fine one");
|
logger.info("--> search with no routing, should fine one");
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch().setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value,
|
prepareSearch().setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value,
|
||||||
equalTo(1L)
|
equalTo(1L)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -146,8 +146,7 @@ public class SimpleRoutingIT extends ESIntegTestCase {
|
||||||
logger.info("--> search with wrong routing, should not find");
|
logger.info("--> search with wrong routing, should not find");
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch()
|
prepareSearch().setRouting("1")
|
||||||
.setRouting("1")
|
|
||||||
.setQuery(QueryBuilders.matchAllQuery())
|
.setQuery(QueryBuilders.matchAllQuery())
|
||||||
.execute()
|
.execute()
|
||||||
.actionGet()
|
.actionGet()
|
||||||
|
@ -156,8 +155,7 @@ public class SimpleRoutingIT extends ESIntegTestCase {
|
||||||
equalTo(0L)
|
equalTo(0L)
|
||||||
);
|
);
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch()
|
prepareSearch().setSize(0)
|
||||||
.setSize(0)
|
|
||||||
.setRouting("1")
|
.setRouting("1")
|
||||||
.setQuery(QueryBuilders.matchAllQuery())
|
.setQuery(QueryBuilders.matchAllQuery())
|
||||||
.execute()
|
.execute()
|
||||||
|
@ -171,8 +169,7 @@ public class SimpleRoutingIT extends ESIntegTestCase {
|
||||||
logger.info("--> search with correct routing, should find");
|
logger.info("--> search with correct routing, should find");
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch()
|
prepareSearch().setRouting(routingValue)
|
||||||
.setRouting(routingValue)
|
|
||||||
.setQuery(QueryBuilders.matchAllQuery())
|
.setQuery(QueryBuilders.matchAllQuery())
|
||||||
.execute()
|
.execute()
|
||||||
.actionGet()
|
.actionGet()
|
||||||
|
@ -181,8 +178,7 @@ public class SimpleRoutingIT extends ESIntegTestCase {
|
||||||
equalTo(1L)
|
equalTo(1L)
|
||||||
);
|
);
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch()
|
prepareSearch().setSize(0)
|
||||||
.setSize(0)
|
|
||||||
.setRouting(routingValue)
|
.setRouting(routingValue)
|
||||||
.setQuery(QueryBuilders.matchAllQuery())
|
.setQuery(QueryBuilders.matchAllQuery())
|
||||||
.execute()
|
.execute()
|
||||||
|
@ -205,17 +201,11 @@ public class SimpleRoutingIT extends ESIntegTestCase {
|
||||||
logger.info("--> search with no routing, should fine two");
|
logger.info("--> search with no routing, should fine two");
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch().setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value,
|
prepareSearch().setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value,
|
||||||
equalTo(2L)
|
equalTo(2L)
|
||||||
);
|
);
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch()
|
prepareSearch().setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value,
|
||||||
.setSize(0)
|
|
||||||
.setQuery(QueryBuilders.matchAllQuery())
|
|
||||||
.execute()
|
|
||||||
.actionGet()
|
|
||||||
.getHits()
|
|
||||||
.getTotalHits().value,
|
|
||||||
equalTo(2L)
|
equalTo(2L)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -223,8 +213,7 @@ public class SimpleRoutingIT extends ESIntegTestCase {
|
||||||
logger.info("--> search with {} routing, should find one", routingValue);
|
logger.info("--> search with {} routing, should find one", routingValue);
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch()
|
prepareSearch().setRouting(routingValue)
|
||||||
.setRouting(routingValue)
|
|
||||||
.setQuery(QueryBuilders.matchAllQuery())
|
.setQuery(QueryBuilders.matchAllQuery())
|
||||||
.execute()
|
.execute()
|
||||||
.actionGet()
|
.actionGet()
|
||||||
|
@ -233,8 +222,7 @@ public class SimpleRoutingIT extends ESIntegTestCase {
|
||||||
equalTo(1L)
|
equalTo(1L)
|
||||||
);
|
);
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch()
|
prepareSearch().setSize(0)
|
||||||
.setSize(0)
|
|
||||||
.setRouting(routingValue)
|
.setRouting(routingValue)
|
||||||
.setQuery(QueryBuilders.matchAllQuery())
|
.setQuery(QueryBuilders.matchAllQuery())
|
||||||
.execute()
|
.execute()
|
||||||
|
@ -248,8 +236,7 @@ public class SimpleRoutingIT extends ESIntegTestCase {
|
||||||
logger.info("--> search with {} routing, should find one", secondRoutingValue);
|
logger.info("--> search with {} routing, should find one", secondRoutingValue);
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch()
|
prepareSearch().setRouting("1")
|
||||||
.setRouting("1")
|
|
||||||
.setQuery(QueryBuilders.matchAllQuery())
|
.setQuery(QueryBuilders.matchAllQuery())
|
||||||
.execute()
|
.execute()
|
||||||
.actionGet()
|
.actionGet()
|
||||||
|
@ -258,8 +245,7 @@ public class SimpleRoutingIT extends ESIntegTestCase {
|
||||||
equalTo(1L)
|
equalTo(1L)
|
||||||
);
|
);
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch()
|
prepareSearch().setSize(0)
|
||||||
.setSize(0)
|
|
||||||
.setRouting(secondRoutingValue)
|
.setRouting(secondRoutingValue)
|
||||||
.setQuery(QueryBuilders.matchAllQuery())
|
.setQuery(QueryBuilders.matchAllQuery())
|
||||||
.execute()
|
.execute()
|
||||||
|
@ -273,8 +259,7 @@ public class SimpleRoutingIT extends ESIntegTestCase {
|
||||||
logger.info("--> search with {},{} indexRoutings , should find two", routingValue, "1");
|
logger.info("--> search with {},{} indexRoutings , should find two", routingValue, "1");
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch()
|
prepareSearch().setRouting(routingValue, secondRoutingValue)
|
||||||
.setRouting(routingValue, secondRoutingValue)
|
|
||||||
.setQuery(QueryBuilders.matchAllQuery())
|
.setQuery(QueryBuilders.matchAllQuery())
|
||||||
.execute()
|
.execute()
|
||||||
.actionGet()
|
.actionGet()
|
||||||
|
@ -283,8 +268,7 @@ public class SimpleRoutingIT extends ESIntegTestCase {
|
||||||
equalTo(2L)
|
equalTo(2L)
|
||||||
);
|
);
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch()
|
prepareSearch().setSize(0)
|
||||||
.setSize(0)
|
|
||||||
.setRouting(routingValue, secondRoutingValue)
|
.setRouting(routingValue, secondRoutingValue)
|
||||||
.setQuery(QueryBuilders.matchAllQuery())
|
.setQuery(QueryBuilders.matchAllQuery())
|
||||||
.execute()
|
.execute()
|
||||||
|
@ -298,8 +282,7 @@ public class SimpleRoutingIT extends ESIntegTestCase {
|
||||||
logger.info("--> search with {},{},{} indexRoutings , should find two", routingValue, secondRoutingValue, routingValue);
|
logger.info("--> search with {},{},{} indexRoutings , should find two", routingValue, secondRoutingValue, routingValue);
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch()
|
prepareSearch().setRouting(routingValue, secondRoutingValue, routingValue)
|
||||||
.setRouting(routingValue, secondRoutingValue, routingValue)
|
|
||||||
.setQuery(QueryBuilders.matchAllQuery())
|
.setQuery(QueryBuilders.matchAllQuery())
|
||||||
.execute()
|
.execute()
|
||||||
.actionGet()
|
.actionGet()
|
||||||
|
@ -308,8 +291,7 @@ public class SimpleRoutingIT extends ESIntegTestCase {
|
||||||
equalTo(2L)
|
equalTo(2L)
|
||||||
);
|
);
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch()
|
prepareSearch().setSize(0)
|
||||||
.setSize(0)
|
|
||||||
.setRouting(routingValue, secondRoutingValue, routingValue)
|
.setRouting(routingValue, secondRoutingValue, routingValue)
|
||||||
.setQuery(QueryBuilders.matchAllQuery())
|
.setQuery(QueryBuilders.matchAllQuery())
|
||||||
.execute()
|
.execute()
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class SearchWithRejectionsIT extends ESIntegTestCase {
|
||||||
SearchType searchType = randomFrom(SearchType.DEFAULT, SearchType.QUERY_THEN_FETCH, SearchType.DFS_QUERY_THEN_FETCH);
|
SearchType searchType = randomFrom(SearchType.DEFAULT, SearchType.QUERY_THEN_FETCH, SearchType.DFS_QUERY_THEN_FETCH);
|
||||||
logger.info("search type is {}", searchType);
|
logger.info("search type is {}", searchType);
|
||||||
for (int i = 0; i < numSearches; i++) {
|
for (int i = 0; i < numSearches; i++) {
|
||||||
responses[i] = client().prepareSearch().setQuery(matchAllQuery()).setSearchType(searchType).execute();
|
responses[i] = prepareSearch().setQuery(matchAllQuery()).setSearchType(searchType).execute();
|
||||||
}
|
}
|
||||||
for (int i = 0; i < numSearches; i++) {
|
for (int i = 0; i < numSearches; i++) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -900,9 +900,9 @@ public class DateHistogramIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPartiallyUnmapped() throws Exception {
|
public void testPartiallyUnmapped() throws Exception {
|
||||||
SearchResponse response = client().prepareSearch("idx", "idx_unmapped")
|
SearchResponse response = prepareSearch("idx", "idx_unmapped").addAggregation(
|
||||||
.addAggregation(dateHistogram("histo").field("date").calendarInterval(DateHistogramInterval.MONTH))
|
dateHistogram("histo").field("date").calendarInterval(DateHistogramInterval.MONTH)
|
||||||
.get();
|
).get();
|
||||||
|
|
||||||
assertNoFailures(response);
|
assertNoFailures(response);
|
||||||
|
|
||||||
|
|
|
@ -510,14 +510,9 @@ public class DateRangeIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPartiallyUnmapped() throws Exception {
|
public void testPartiallyUnmapped() throws Exception {
|
||||||
SearchResponse response = client().prepareSearch("idx", "idx_unmapped")
|
SearchResponse response = prepareSearch("idx", "idx_unmapped").addAggregation(
|
||||||
.addAggregation(
|
dateRange("range").field("date").addUnboundedTo(date(2, 15)).addRange(date(2, 15), date(3, 15)).addUnboundedFrom(date(3, 15))
|
||||||
dateRange("range").field("date")
|
).get();
|
||||||
.addUnboundedTo(date(2, 15))
|
|
||||||
.addRange(date(2, 15), date(3, 15))
|
|
||||||
.addUnboundedFrom(date(3, 15))
|
|
||||||
)
|
|
||||||
.get();
|
|
||||||
|
|
||||||
assertNoFailures(response);
|
assertNoFailures(response);
|
||||||
|
|
||||||
|
|
|
@ -205,8 +205,7 @@ public class DiversifiedSamplerIT extends ESIntegTestCase {
|
||||||
.field("author")
|
.field("author")
|
||||||
.maxDocsPerValue(1);
|
.maxDocsPerValue(1);
|
||||||
sampleAgg.subAggregation(terms("authors").field("author"));
|
sampleAgg.subAggregation(terms("authors").field("author"));
|
||||||
SearchResponse response = client().prepareSearch("idx_unmapped_author", "test")
|
SearchResponse response = prepareSearch("idx_unmapped_author", "test").setSearchType(SearchType.QUERY_THEN_FETCH)
|
||||||
.setSearchType(SearchType.QUERY_THEN_FETCH)
|
|
||||||
.setQuery(new TermQueryBuilder("genre", "fantasy"))
|
.setQuery(new TermQueryBuilder("genre", "fantasy"))
|
||||||
.setFrom(0)
|
.setFrom(0)
|
||||||
.setSize(60)
|
.setSize(60)
|
||||||
|
@ -225,8 +224,7 @@ public class DiversifiedSamplerIT extends ESIntegTestCase {
|
||||||
DiversifiedAggregationBuilder sampleAgg = new DiversifiedAggregationBuilder("sample").shardSize(100);
|
DiversifiedAggregationBuilder sampleAgg = new DiversifiedAggregationBuilder("sample").shardSize(100);
|
||||||
sampleAgg.field("author").maxDocsPerValue(MAX_DOCS_PER_AUTHOR).executionHint(randomExecutionHint());
|
sampleAgg.field("author").maxDocsPerValue(MAX_DOCS_PER_AUTHOR).executionHint(randomExecutionHint());
|
||||||
sampleAgg.subAggregation(terms("authors").field("author"));
|
sampleAgg.subAggregation(terms("authors").field("author"));
|
||||||
SearchResponse response = client().prepareSearch("idx_unmapped", "idx_unmapped_author")
|
SearchResponse response = prepareSearch("idx_unmapped", "idx_unmapped_author").setSearchType(SearchType.QUERY_THEN_FETCH)
|
||||||
.setSearchType(SearchType.QUERY_THEN_FETCH)
|
|
||||||
.setQuery(new TermQueryBuilder("genre", "fantasy"))
|
.setQuery(new TermQueryBuilder("genre", "fantasy"))
|
||||||
.setFrom(0)
|
.setFrom(0)
|
||||||
.setSize(60)
|
.setSize(60)
|
||||||
|
|
|
@ -453,11 +453,9 @@ public class DoubleTermsIT extends AbstractTermsTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPartiallyUnmapped() throws Exception {
|
public void testPartiallyUnmapped() throws Exception {
|
||||||
SearchResponse response = client().prepareSearch("idx_unmapped", "idx")
|
SearchResponse response = prepareSearch("idx_unmapped", "idx").addAggregation(
|
||||||
.addAggregation(
|
new TermsAggregationBuilder("terms").field(SINGLE_VALUED_FIELD_NAME).collectMode(randomFrom(SubAggCollectionMode.values()))
|
||||||
new TermsAggregationBuilder("terms").field(SINGLE_VALUED_FIELD_NAME).collectMode(randomFrom(SubAggCollectionMode.values()))
|
).get();
|
||||||
)
|
|
||||||
.get();
|
|
||||||
|
|
||||||
assertNoFailures(response);
|
assertNoFailures(response);
|
||||||
|
|
||||||
|
@ -476,13 +474,11 @@ public class DoubleTermsIT extends AbstractTermsTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPartiallyUnmappedWithFormat() throws Exception {
|
public void testPartiallyUnmappedWithFormat() throws Exception {
|
||||||
SearchResponse response = client().prepareSearch("idx_unmapped", "idx")
|
SearchResponse response = prepareSearch("idx_unmapped", "idx").addAggregation(
|
||||||
.addAggregation(
|
new TermsAggregationBuilder("terms").field(SINGLE_VALUED_FIELD_NAME)
|
||||||
new TermsAggregationBuilder("terms").field(SINGLE_VALUED_FIELD_NAME)
|
.collectMode(randomFrom(SubAggCollectionMode.values()))
|
||||||
.collectMode(randomFrom(SubAggCollectionMode.values()))
|
.format("0000.00")
|
||||||
.format("0000.00")
|
).get();
|
||||||
)
|
|
||||||
.get();
|
|
||||||
|
|
||||||
assertNoFailures(response);
|
assertNoFailures(response);
|
||||||
|
|
||||||
|
|
|
@ -273,15 +273,13 @@ public class GeoDistanceIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPartiallyUnmapped() throws Exception {
|
public void testPartiallyUnmapped() throws Exception {
|
||||||
SearchResponse response = client().prepareSearch("idx", "idx_unmapped")
|
SearchResponse response = prepareSearch("idx", "idx_unmapped").addAggregation(
|
||||||
.addAggregation(
|
geoDistance("amsterdam_rings", new GeoPoint(52.3760, 4.894)).field("location")
|
||||||
geoDistance("amsterdam_rings", new GeoPoint(52.3760, 4.894)).field("location")
|
.unit(DistanceUnit.KILOMETERS)
|
||||||
.unit(DistanceUnit.KILOMETERS)
|
.addUnboundedTo(500)
|
||||||
.addUnboundedTo(500)
|
.addRange(500, 1000)
|
||||||
.addRange(500, 1000)
|
.addUnboundedFrom(1000)
|
||||||
.addUnboundedFrom(1000)
|
).get();
|
||||||
)
|
|
||||||
.get();
|
|
||||||
|
|
||||||
assertNoFailures(response);
|
assertNoFailures(response);
|
||||||
|
|
||||||
|
|
|
@ -218,9 +218,9 @@ public class GeoHashGridIT extends ESIntegTestCase {
|
||||||
|
|
||||||
public void testPartiallyUnmapped() throws Exception {
|
public void testPartiallyUnmapped() throws Exception {
|
||||||
for (int precision = 1; precision <= PRECISION; precision++) {
|
for (int precision = 1; precision <= PRECISION; precision++) {
|
||||||
SearchResponse response = client().prepareSearch("idx", "idx_unmapped")
|
SearchResponse response = prepareSearch("idx", "idx_unmapped").addAggregation(
|
||||||
.addAggregation(geohashGrid("geohashgrid").field("location").precision(precision))
|
geohashGrid("geohashgrid").field("location").precision(precision)
|
||||||
.get();
|
).get();
|
||||||
|
|
||||||
assertNoFailures(response);
|
assertNoFailures(response);
|
||||||
|
|
||||||
|
|
|
@ -825,9 +825,9 @@ public class HistogramIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPartiallyUnmapped() throws Exception {
|
public void testPartiallyUnmapped() throws Exception {
|
||||||
SearchResponse response = client().prepareSearch("idx", "idx_unmapped")
|
SearchResponse response = prepareSearch("idx", "idx_unmapped").addAggregation(
|
||||||
.addAggregation(histogram("histo").field(SINGLE_VALUED_FIELD_NAME).interval(interval))
|
histogram("histo").field(SINGLE_VALUED_FIELD_NAME).interval(interval)
|
||||||
.get();
|
).get();
|
||||||
|
|
||||||
assertNoFailures(response);
|
assertNoFailures(response);
|
||||||
|
|
||||||
|
@ -846,13 +846,11 @@ public class HistogramIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPartiallyUnmappedWithExtendedBounds() throws Exception {
|
public void testPartiallyUnmappedWithExtendedBounds() throws Exception {
|
||||||
SearchResponse response = client().prepareSearch("idx", "idx_unmapped")
|
SearchResponse response = prepareSearch("idx", "idx_unmapped").addAggregation(
|
||||||
.addAggregation(
|
histogram("histo").field(SINGLE_VALUED_FIELD_NAME)
|
||||||
histogram("histo").field(SINGLE_VALUED_FIELD_NAME)
|
.interval(interval)
|
||||||
.interval(interval)
|
.extendedBounds(-1 * 2 * interval, valueCounts.length * interval)
|
||||||
.extendedBounds(-1 * 2 * interval, valueCounts.length * interval)
|
).get();
|
||||||
)
|
|
||||||
.get();
|
|
||||||
|
|
||||||
assertNoFailures(response);
|
assertNoFailures(response);
|
||||||
|
|
||||||
|
|
|
@ -151,15 +151,13 @@ public class IpRangeIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPartiallyUnmapped() {
|
public void testPartiallyUnmapped() {
|
||||||
SearchResponse rsp = client().prepareSearch("idx", "idx_unmapped")
|
SearchResponse rsp = prepareSearch("idx", "idx_unmapped").addAggregation(
|
||||||
.addAggregation(
|
AggregationBuilders.ipRange("my_range")
|
||||||
AggregationBuilders.ipRange("my_range")
|
.field("ip")
|
||||||
.field("ip")
|
.addUnboundedTo("192.168.1.0")
|
||||||
.addUnboundedTo("192.168.1.0")
|
.addRange("192.168.1.0", "192.168.1.10")
|
||||||
.addRange("192.168.1.0", "192.168.1.10")
|
.addUnboundedFrom("192.168.1.10")
|
||||||
.addUnboundedFrom("192.168.1.10")
|
).get();
|
||||||
)
|
|
||||||
.get();
|
|
||||||
assertNoFailures(rsp);
|
assertNoFailures(rsp);
|
||||||
Range range = rsp.getAggregations().get("my_range");
|
Range range = rsp.getAggregations().get("my_range");
|
||||||
assertEquals(3, range.getBuckets().size());
|
assertEquals(3, range.getBuckets().size());
|
||||||
|
|
|
@ -450,11 +450,9 @@ public class LongTermsIT extends AbstractTermsTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPartiallyUnmapped() throws Exception {
|
public void testPartiallyUnmapped() throws Exception {
|
||||||
SearchResponse response = client().prepareSearch("idx_unmapped", "idx")
|
SearchResponse response = prepareSearch("idx_unmapped", "idx").addAggregation(
|
||||||
.addAggregation(
|
new TermsAggregationBuilder("terms").field(SINGLE_VALUED_FIELD_NAME).collectMode(randomFrom(SubAggCollectionMode.values()))
|
||||||
new TermsAggregationBuilder("terms").field(SINGLE_VALUED_FIELD_NAME).collectMode(randomFrom(SubAggCollectionMode.values()))
|
).get();
|
||||||
)
|
|
||||||
.get();
|
|
||||||
|
|
||||||
assertNoFailures(response);
|
assertNoFailures(response);
|
||||||
|
|
||||||
|
@ -473,13 +471,11 @@ public class LongTermsIT extends AbstractTermsTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPartiallyUnmappedWithFormat() throws Exception {
|
public void testPartiallyUnmappedWithFormat() throws Exception {
|
||||||
SearchResponse response = client().prepareSearch("idx_unmapped", "idx")
|
SearchResponse response = prepareSearch("idx_unmapped", "idx").addAggregation(
|
||||||
.addAggregation(
|
new TermsAggregationBuilder("terms").field(SINGLE_VALUED_FIELD_NAME)
|
||||||
new TermsAggregationBuilder("terms").field(SINGLE_VALUED_FIELD_NAME)
|
.collectMode(randomFrom(SubAggCollectionMode.values()))
|
||||||
.collectMode(randomFrom(SubAggCollectionMode.values()))
|
.format("0000")
|
||||||
.format("0000")
|
).get();
|
||||||
)
|
|
||||||
.get();
|
|
||||||
|
|
||||||
assertNoFailures(response);
|
assertNoFailures(response);
|
||||||
|
|
||||||
|
|
|
@ -759,9 +759,9 @@ public class RangeIT extends ESIntegTestCase {
|
||||||
public void testPartiallyUnmapped() throws Exception {
|
public void testPartiallyUnmapped() throws Exception {
|
||||||
clusterAdmin().prepareHealth("idx_unmapped").setWaitForYellowStatus().get();
|
clusterAdmin().prepareHealth("idx_unmapped").setWaitForYellowStatus().get();
|
||||||
|
|
||||||
SearchResponse response = client().prepareSearch("idx", "idx_unmapped")
|
SearchResponse response = prepareSearch("idx", "idx_unmapped").addAggregation(
|
||||||
.addAggregation(range("range").field(SINGLE_VALUED_FIELD_NAME).addUnboundedTo(3).addRange(3, 6).addUnboundedFrom(6))
|
range("range").field(SINGLE_VALUED_FIELD_NAME).addUnboundedTo(3).addRange(3, 6).addUnboundedFrom(6)
|
||||||
.get();
|
).get();
|
||||||
|
|
||||||
assertNoFailures(response);
|
assertNoFailures(response);
|
||||||
|
|
||||||
|
@ -961,9 +961,9 @@ public class RangeIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testFieldAlias() {
|
public void testFieldAlias() {
|
||||||
SearchResponse response = client().prepareSearch("old_index", "new_index")
|
SearchResponse response = prepareSearch("old_index", "new_index").addAggregation(
|
||||||
.addAggregation(range("range").field("route_length_miles").addUnboundedTo(50.0).addRange(50.0, 150.0).addUnboundedFrom(150.0))
|
range("range").field("route_length_miles").addUnboundedTo(50.0).addRange(50.0, 150.0).addUnboundedFrom(150.0)
|
||||||
.get();
|
).get();
|
||||||
|
|
||||||
assertNoFailures(response);
|
assertNoFailures(response);
|
||||||
|
|
||||||
|
@ -990,11 +990,9 @@ public class RangeIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testFieldAliasWithMissingValue() {
|
public void testFieldAliasWithMissingValue() {
|
||||||
SearchResponse response = client().prepareSearch("old_index", "new_index")
|
SearchResponse response = prepareSearch("old_index", "new_index").addAggregation(
|
||||||
.addAggregation(
|
range("range").field("route_length_miles").missing(0.0).addUnboundedTo(50.0).addRange(50.0, 150.0).addUnboundedFrom(150.0)
|
||||||
range("range").field("route_length_miles").missing(0.0).addUnboundedTo(50.0).addRange(50.0, 150.0).addUnboundedFrom(150.0)
|
).get();
|
||||||
)
|
|
||||||
.get();
|
|
||||||
|
|
||||||
assertNoFailures(response);
|
assertNoFailures(response);
|
||||||
|
|
||||||
|
|
|
@ -158,8 +158,7 @@ public class SamplerIT extends ESIntegTestCase {
|
||||||
public void testPartiallyUnmappedChildAggNoDiversity() throws Exception {
|
public void testPartiallyUnmappedChildAggNoDiversity() throws Exception {
|
||||||
SamplerAggregationBuilder sampleAgg = sampler("sample").shardSize(100);
|
SamplerAggregationBuilder sampleAgg = sampler("sample").shardSize(100);
|
||||||
sampleAgg.subAggregation(terms("authors").field("author"));
|
sampleAgg.subAggregation(terms("authors").field("author"));
|
||||||
SearchResponse response = client().prepareSearch("idx_unmapped", "test")
|
SearchResponse response = prepareSearch("idx_unmapped", "test").setSearchType(SearchType.QUERY_THEN_FETCH)
|
||||||
.setSearchType(SearchType.QUERY_THEN_FETCH)
|
|
||||||
.setQuery(new TermQueryBuilder("genre", "fantasy"))
|
.setQuery(new TermQueryBuilder("genre", "fantasy"))
|
||||||
.setFrom(0)
|
.setFrom(0)
|
||||||
.setSize(60)
|
.setSize(60)
|
||||||
|
|
|
@ -960,16 +960,14 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
|
||||||
* 3 one-shard indices.
|
* 3 one-shard indices.
|
||||||
*/
|
*/
|
||||||
public void testFixedDocs() throws Exception {
|
public void testFixedDocs() throws Exception {
|
||||||
SearchResponse response = client().prepareSearch("idx_fixed_docs_0", "idx_fixed_docs_1", "idx_fixed_docs_2")
|
SearchResponse response = prepareSearch("idx_fixed_docs_0", "idx_fixed_docs_1", "idx_fixed_docs_2").addAggregation(
|
||||||
.addAggregation(
|
terms("terms").executionHint(randomExecutionHint())
|
||||||
terms("terms").executionHint(randomExecutionHint())
|
.field(STRING_FIELD_NAME)
|
||||||
.field(STRING_FIELD_NAME)
|
.showTermDocCountError(true)
|
||||||
.showTermDocCountError(true)
|
.size(5)
|
||||||
.size(5)
|
.shardSize(5)
|
||||||
.shardSize(5)
|
.collectMode(randomFrom(SubAggCollectionMode.values()))
|
||||||
.collectMode(randomFrom(SubAggCollectionMode.values()))
|
).get();
|
||||||
)
|
|
||||||
.get();
|
|
||||||
assertNoFailures(response);
|
assertNoFailures(response);
|
||||||
|
|
||||||
Terms terms = response.getAggregations().get("terms");
|
Terms terms = response.getAggregations().get("terms");
|
||||||
|
@ -1015,16 +1013,14 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
|
||||||
* See https://github.com/elastic/elasticsearch/issues/40005 for more details
|
* See https://github.com/elastic/elasticsearch/issues/40005 for more details
|
||||||
*/
|
*/
|
||||||
public void testIncrementalReduction() {
|
public void testIncrementalReduction() {
|
||||||
SearchResponse response = client().prepareSearch("idx_fixed_docs_3", "idx_fixed_docs_4", "idx_fixed_docs_5")
|
SearchResponse response = prepareSearch("idx_fixed_docs_3", "idx_fixed_docs_4", "idx_fixed_docs_5").addAggregation(
|
||||||
.addAggregation(
|
terms("terms").executionHint(randomExecutionHint())
|
||||||
terms("terms").executionHint(randomExecutionHint())
|
.field(STRING_FIELD_NAME)
|
||||||
.field(STRING_FIELD_NAME)
|
.showTermDocCountError(true)
|
||||||
.showTermDocCountError(true)
|
.size(5)
|
||||||
.size(5)
|
.shardSize(5)
|
||||||
.shardSize(5)
|
.collectMode(randomFrom(SubAggCollectionMode.values()))
|
||||||
.collectMode(randomFrom(SubAggCollectionMode.values()))
|
).get();
|
||||||
)
|
|
||||||
.get();
|
|
||||||
assertNoFailures(response);
|
assertNoFailures(response);
|
||||||
Terms terms = response.getAggregations().get("terms");
|
Terms terms = response.getAggregations().get("terms");
|
||||||
assertThat(terms.getDocCountError(), equalTo(0L));
|
assertThat(terms.getDocCountError(), equalTo(0L));
|
||||||
|
|
|
@ -533,13 +533,11 @@ public class StringTermsIT extends AbstractTermsTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPartiallyUnmapped() throws Exception {
|
public void testPartiallyUnmapped() throws Exception {
|
||||||
SearchResponse response = client().prepareSearch("idx", "idx_unmapped")
|
SearchResponse response = prepareSearch("idx", "idx_unmapped").addAggregation(
|
||||||
.addAggregation(
|
new TermsAggregationBuilder("terms").executionHint(randomExecutionHint())
|
||||||
new TermsAggregationBuilder("terms").executionHint(randomExecutionHint())
|
.field(SINGLE_VALUED_FIELD_NAME)
|
||||||
.field(SINGLE_VALUED_FIELD_NAME)
|
.collectMode(randomFrom(SubAggCollectionMode.values()))
|
||||||
.collectMode(randomFrom(SubAggCollectionMode.values()))
|
).get();
|
||||||
)
|
|
||||||
.get();
|
|
||||||
|
|
||||||
assertNoFailures(response);
|
assertNoFailures(response);
|
||||||
|
|
||||||
|
@ -1125,13 +1123,11 @@ public class StringTermsIT extends AbstractTermsTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testIndexMetaField() throws Exception {
|
public void testIndexMetaField() throws Exception {
|
||||||
SearchResponse response = client().prepareSearch("idx", "empty_bucket_idx")
|
SearchResponse response = prepareSearch("idx", "empty_bucket_idx").addAggregation(
|
||||||
.addAggregation(
|
new TermsAggregationBuilder("terms").collectMode(randomFrom(SubAggCollectionMode.values()))
|
||||||
new TermsAggregationBuilder("terms").collectMode(randomFrom(SubAggCollectionMode.values()))
|
.executionHint(randomExecutionHint())
|
||||||
.executionHint(randomExecutionHint())
|
.field(IndexFieldMapper.NAME)
|
||||||
.field(IndexFieldMapper.NAME)
|
).get();
|
||||||
)
|
|
||||||
.get();
|
|
||||||
|
|
||||||
assertNoFailures(response);
|
assertNoFailures(response);
|
||||||
StringTerms terms = response.getAggregations().get("terms");
|
StringTerms terms = response.getAggregations().get("terms");
|
||||||
|
|
|
@ -160,8 +160,7 @@ public class ExtendedStatsIT extends AbstractNumericTestCase {
|
||||||
.get()
|
.get()
|
||||||
.getAggregations()
|
.getAggregations()
|
||||||
.get("stats");
|
.get("stats");
|
||||||
ExtendedStats s2 = client().prepareSearch("idx", "idx_unmapped")
|
ExtendedStats s2 = prepareSearch("idx", "idx_unmapped").addAggregation(extendedStats("stats").field("value").sigma(sigma))
|
||||||
.addAggregation(extendedStats("stats").field("value").sigma(sigma))
|
|
||||||
.get()
|
.get()
|
||||||
.getAggregations()
|
.getAggregations()
|
||||||
.get("stats");
|
.get("stats");
|
||||||
|
@ -343,8 +342,7 @@ public class ExtendedStatsIT extends AbstractNumericTestCase {
|
||||||
@Override
|
@Override
|
||||||
public void testSingleValuedFieldPartiallyUnmapped() throws Exception {
|
public void testSingleValuedFieldPartiallyUnmapped() throws Exception {
|
||||||
double sigma = randomDouble() * randomIntBetween(1, 10);
|
double sigma = randomDouble() * randomIntBetween(1, 10);
|
||||||
SearchResponse searchResponse = client().prepareSearch("idx", "idx_unmapped")
|
SearchResponse searchResponse = prepareSearch("idx", "idx_unmapped").setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addAggregation(extendedStats("stats").field("value").sigma(sigma))
|
.addAggregation(extendedStats("stats").field("value").sigma(sigma))
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
|
|
|
@ -248,8 +248,7 @@ public class HDRPercentileRanksIT extends AbstractNumericTestCase {
|
||||||
public void testSingleValuedFieldPartiallyUnmapped() throws Exception {
|
public void testSingleValuedFieldPartiallyUnmapped() throws Exception {
|
||||||
int sigDigits = randomSignificantDigits();
|
int sigDigits = randomSignificantDigits();
|
||||||
final double[] pcts = randomPercents(minValue, maxValue);
|
final double[] pcts = randomPercents(minValue, maxValue);
|
||||||
SearchResponse searchResponse = client().prepareSearch("idx", "idx_unmapped")
|
SearchResponse searchResponse = prepareSearch("idx", "idx_unmapped").setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addAggregation(
|
.addAggregation(
|
||||||
percentileRanks("percentile_ranks", pcts).method(PercentilesMethod.HDR)
|
percentileRanks("percentile_ranks", pcts).method(PercentilesMethod.HDR)
|
||||||
.numberOfSignificantValueDigits(sigDigits)
|
.numberOfSignificantValueDigits(sigDigits)
|
||||||
|
|
|
@ -206,8 +206,7 @@ public class HDRPercentilesIT extends AbstractNumericTestCase {
|
||||||
public void testSingleValuedFieldPartiallyUnmapped() throws Exception {
|
public void testSingleValuedFieldPartiallyUnmapped() throws Exception {
|
||||||
final double[] pcts = randomPercentiles();
|
final double[] pcts = randomPercentiles();
|
||||||
int sigDigits = randomSignificantDigits();
|
int sigDigits = randomSignificantDigits();
|
||||||
SearchResponse searchResponse = client().prepareSearch("idx", "idx_unmapped")
|
SearchResponse searchResponse = prepareSearch("idx", "idx_unmapped").setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addAggregation(
|
.addAggregation(
|
||||||
percentiles("percentiles").numberOfSignificantValueDigits(sigDigits)
|
percentiles("percentiles").numberOfSignificantValueDigits(sigDigits)
|
||||||
.method(PercentilesMethod.HDR)
|
.method(PercentilesMethod.HDR)
|
||||||
|
|
|
@ -195,8 +195,7 @@ public class MedianAbsoluteDeviationIT extends AbstractNumericTestCase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void testSingleValuedFieldPartiallyUnmapped() throws Exception {
|
public void testSingleValuedFieldPartiallyUnmapped() throws Exception {
|
||||||
final SearchResponse response = client().prepareSearch("idx", "idx_unmapped")
|
final SearchResponse response = prepareSearch("idx", "idx_unmapped").setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addAggregation(randomBuilder().field("value"))
|
.addAggregation(randomBuilder().field("value"))
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
|
|
|
@ -270,9 +270,7 @@ public class SumIT extends AbstractNumericTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testFieldAlias() {
|
public void testFieldAlias() {
|
||||||
SearchResponse response = client().prepareSearch("old_index", "new_index")
|
SearchResponse response = prepareSearch("old_index", "new_index").addAggregation(sum("sum").field("route_length_miles")).get();
|
||||||
.addAggregation(sum("sum").field("route_length_miles"))
|
|
||||||
.get();
|
|
||||||
|
|
||||||
assertNoFailures(response);
|
assertNoFailures(response);
|
||||||
|
|
||||||
|
@ -283,9 +281,9 @@ public class SumIT extends AbstractNumericTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testFieldAliasInSubAggregation() {
|
public void testFieldAliasInSubAggregation() {
|
||||||
SearchResponse response = client().prepareSearch("old_index", "new_index")
|
SearchResponse response = prepareSearch("old_index", "new_index").addAggregation(
|
||||||
.addAggregation(terms("terms").field("transit_mode").subAggregation(sum("sum").field("route_length_miles")))
|
terms("terms").field("transit_mode").subAggregation(sum("sum").field("route_length_miles"))
|
||||||
.get();
|
).get();
|
||||||
|
|
||||||
assertNoFailures(response);
|
assertNoFailures(response);
|
||||||
|
|
||||||
|
|
|
@ -207,8 +207,7 @@ public class TDigestPercentileRanksIT extends AbstractNumericTestCase {
|
||||||
@Override
|
@Override
|
||||||
public void testSingleValuedFieldPartiallyUnmapped() throws Exception {
|
public void testSingleValuedFieldPartiallyUnmapped() throws Exception {
|
||||||
final double[] pcts = randomPercents(minValue, maxValue);
|
final double[] pcts = randomPercents(minValue, maxValue);
|
||||||
SearchResponse searchResponse = client().prepareSearch("idx", "idx_unmapped")
|
SearchResponse searchResponse = prepareSearch("idx", "idx_unmapped").setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addAggregation(randomCompression(percentileRanks("percentile_ranks", pcts)).field("value"))
|
.addAggregation(randomCompression(percentileRanks("percentile_ranks", pcts)).field("value"))
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
|
|
|
@ -179,8 +179,7 @@ public class TDigestPercentilesIT extends AbstractNumericTestCase {
|
||||||
@Override
|
@Override
|
||||||
public void testSingleValuedFieldPartiallyUnmapped() throws Exception {
|
public void testSingleValuedFieldPartiallyUnmapped() throws Exception {
|
||||||
final double[] pcts = randomPercentiles();
|
final double[] pcts = randomPercentiles();
|
||||||
SearchResponse searchResponse = client().prepareSearch("idx", "idx_unmapped")
|
SearchResponse searchResponse = prepareSearch("idx", "idx_unmapped").setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addAggregation(randomCompression(percentiles("percentiles")).field("value").percentiles(pcts))
|
.addAggregation(randomCompression(percentiles("percentiles")).field("value").percentiles(pcts))
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
|
|
|
@ -114,8 +114,7 @@ public class ValueCountIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSingleValuedFieldPartiallyUnmapped() throws Exception {
|
public void testSingleValuedFieldPartiallyUnmapped() throws Exception {
|
||||||
SearchResponse searchResponse = client().prepareSearch("idx", "idx_unmapped")
|
SearchResponse searchResponse = prepareSearch("idx", "idx_unmapped").setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addAggregation(count("count").field("value"))
|
.addAggregation(count("count").field("value"))
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
|
|
|
@ -588,24 +588,22 @@ public class BucketScriptIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPartiallyUnmapped() throws Exception {
|
public void testPartiallyUnmapped() throws Exception {
|
||||||
SearchResponse response = client().prepareSearch("idx", "idx_unmapped")
|
SearchResponse response = prepareSearch("idx", "idx_unmapped").addAggregation(
|
||||||
.addAggregation(
|
histogram("histo").field(FIELD_1_NAME)
|
||||||
histogram("histo").field(FIELD_1_NAME)
|
.interval(interval)
|
||||||
.interval(interval)
|
.subAggregation(sum("field2Sum").field(FIELD_2_NAME))
|
||||||
.subAggregation(sum("field2Sum").field(FIELD_2_NAME))
|
.subAggregation(sum("field3Sum").field(FIELD_3_NAME))
|
||||||
.subAggregation(sum("field3Sum").field(FIELD_3_NAME))
|
.subAggregation(sum("field4Sum").field(FIELD_4_NAME))
|
||||||
.subAggregation(sum("field4Sum").field(FIELD_4_NAME))
|
.subAggregation(
|
||||||
.subAggregation(
|
bucketScript(
|
||||||
bucketScript(
|
"seriesArithmetic",
|
||||||
"seriesArithmetic",
|
new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_value0 + _value1 + _value2", Collections.emptyMap()),
|
||||||
new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_value0 + _value1 + _value2", Collections.emptyMap()),
|
"field2Sum",
|
||||||
"field2Sum",
|
"field3Sum",
|
||||||
"field3Sum",
|
"field4Sum"
|
||||||
"field4Sum"
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.get();
|
).get();
|
||||||
|
|
||||||
assertNoFailures(response);
|
assertNoFailures(response);
|
||||||
|
|
||||||
|
@ -651,14 +649,12 @@ public class BucketScriptIT extends ESIntegTestCase {
|
||||||
"seriesArithmetic"
|
"seriesArithmetic"
|
||||||
);
|
);
|
||||||
|
|
||||||
SearchResponse response = client().prepareSearch("idx", "idx_unmapped")
|
SearchResponse response = prepareSearch("idx", "idx_unmapped").addAggregation(
|
||||||
.addAggregation(
|
histogram("histo").field(FIELD_1_NAME)
|
||||||
histogram("histo").field(FIELD_1_NAME)
|
.interval(interval)
|
||||||
.interval(interval)
|
.subAggregation(sum("field2Sum").field(FIELD_2_NAME))
|
||||||
.subAggregation(sum("field2Sum").field(FIELD_2_NAME))
|
.subAggregation(bucketScriptAgg)
|
||||||
.subAggregation(bucketScriptAgg)
|
).get();
|
||||||
)
|
|
||||||
.get();
|
|
||||||
|
|
||||||
assertNoFailures(response);
|
assertNoFailures(response);
|
||||||
|
|
||||||
|
@ -698,16 +694,14 @@ public class BucketScriptIT extends ESIntegTestCase {
|
||||||
"seriesArithmetic"
|
"seriesArithmetic"
|
||||||
);
|
);
|
||||||
|
|
||||||
SearchResponse response = client().prepareSearch("idx", "idx_unmapped")
|
SearchResponse response = prepareSearch("idx", "idx_unmapped").addAggregation(
|
||||||
.addAggregation(
|
histogram("histo").field(FIELD_1_NAME)
|
||||||
histogram("histo").field(FIELD_1_NAME)
|
.interval(interval)
|
||||||
.interval(interval)
|
.subAggregation(sum("field2Sum").field(FIELD_2_NAME))
|
||||||
.subAggregation(sum("field2Sum").field(FIELD_2_NAME))
|
.subAggregation(sum("field3Sum").field(FIELD_3_NAME))
|
||||||
.subAggregation(sum("field3Sum").field(FIELD_3_NAME))
|
.subAggregation(sum("field4Sum").field(FIELD_4_NAME))
|
||||||
.subAggregation(sum("field4Sum").field(FIELD_4_NAME))
|
.subAggregation(bucketScriptAgg)
|
||||||
.subAggregation(bucketScriptAgg)
|
).get();
|
||||||
)
|
|
||||||
.get();
|
|
||||||
|
|
||||||
assertNoFailures(response);
|
assertNoFailures(response);
|
||||||
|
|
||||||
|
@ -757,16 +751,14 @@ public class BucketScriptIT extends ESIntegTestCase {
|
||||||
"seriesArithmetic"
|
"seriesArithmetic"
|
||||||
);
|
);
|
||||||
|
|
||||||
SearchResponse response = client().prepareSearch("idx", "idx_unmapped")
|
SearchResponse response = prepareSearch("idx", "idx_unmapped").addAggregation(
|
||||||
.addAggregation(
|
histogram("histo").field(FIELD_1_NAME)
|
||||||
histogram("histo").field(FIELD_1_NAME)
|
.interval(interval)
|
||||||
.interval(interval)
|
.subAggregation(sum("field2Sum").field(FIELD_2_NAME))
|
||||||
.subAggregation(sum("field2Sum").field(FIELD_2_NAME))
|
.subAggregation(sum("field3Sum").field(FIELD_3_NAME))
|
||||||
.subAggregation(sum("field3Sum").field(FIELD_3_NAME))
|
.subAggregation(sum("field4Sum").field(FIELD_4_NAME))
|
||||||
.subAggregation(sum("field4Sum").field(FIELD_4_NAME))
|
.subAggregation(bucketScriptAgg)
|
||||||
.subAggregation(bucketScriptAgg)
|
).get();
|
||||||
)
|
|
||||||
.get();
|
|
||||||
|
|
||||||
assertNoFailures(response);
|
assertNoFailures(response);
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class SearchRedStateIndexIT extends ESIntegTestCase {
|
||||||
final int numShards = cluster().numDataNodes() + 2;
|
final int numShards = cluster().numDataNodes() + 2;
|
||||||
buildRedIndex(numShards);
|
buildRedIndex(numShards);
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch().setSize(0).setAllowPartialSearchResults(true).get();
|
SearchResponse searchResponse = prepareSearch().setSize(0).setAllowPartialSearchResults(true).get();
|
||||||
assertThat(RestStatus.OK, equalTo(searchResponse.status()));
|
assertThat(RestStatus.OK, equalTo(searchResponse.status()));
|
||||||
assertThat("Expect some shards failed", searchResponse.getFailedShards(), allOf(greaterThan(0), lessThanOrEqualTo(numShards)));
|
assertThat("Expect some shards failed", searchResponse.getFailedShards(), allOf(greaterThan(0), lessThanOrEqualTo(numShards)));
|
||||||
assertThat("Expect no shards skipped", searchResponse.getSkippedShards(), equalTo(0));
|
assertThat("Expect no shards skipped", searchResponse.getSkippedShards(), equalTo(0));
|
||||||
|
@ -60,7 +60,7 @@ public class SearchRedStateIndexIT extends ESIntegTestCase {
|
||||||
|
|
||||||
setClusterDefaultAllowPartialResults(true);
|
setClusterDefaultAllowPartialResults(true);
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch().setSize(0).get();
|
SearchResponse searchResponse = prepareSearch().setSize(0).get();
|
||||||
assertThat(RestStatus.OK, equalTo(searchResponse.status()));
|
assertThat(RestStatus.OK, equalTo(searchResponse.status()));
|
||||||
assertThat("Expect some shards failed", searchResponse.getFailedShards(), allOf(greaterThan(0), lessThanOrEqualTo(numShards)));
|
assertThat("Expect some shards failed", searchResponse.getFailedShards(), allOf(greaterThan(0), lessThanOrEqualTo(numShards)));
|
||||||
assertThat("Expect no shards skipped", searchResponse.getSkippedShards(), equalTo(0));
|
assertThat("Expect no shards skipped", searchResponse.getSkippedShards(), equalTo(0));
|
||||||
|
@ -79,7 +79,7 @@ public class SearchRedStateIndexIT extends ESIntegTestCase {
|
||||||
|
|
||||||
SearchPhaseExecutionException ex = expectThrows(
|
SearchPhaseExecutionException ex = expectThrows(
|
||||||
SearchPhaseExecutionException.class,
|
SearchPhaseExecutionException.class,
|
||||||
() -> client().prepareSearch().setSize(0).setAllowPartialSearchResults(false).get()
|
() -> prepareSearch().setSize(0).setAllowPartialSearchResults(false).get()
|
||||||
);
|
);
|
||||||
assertThat(ex.getDetailedMessage(), containsString("Search rejected due to missing shard"));
|
assertThat(ex.getDetailedMessage(), containsString("Search rejected due to missing shard"));
|
||||||
}
|
}
|
||||||
|
@ -88,10 +88,7 @@ public class SearchRedStateIndexIT extends ESIntegTestCase {
|
||||||
buildRedIndex(cluster().numDataNodes() + 2);
|
buildRedIndex(cluster().numDataNodes() + 2);
|
||||||
|
|
||||||
setClusterDefaultAllowPartialResults(false);
|
setClusterDefaultAllowPartialResults(false);
|
||||||
SearchPhaseExecutionException ex = expectThrows(
|
SearchPhaseExecutionException ex = expectThrows(SearchPhaseExecutionException.class, () -> prepareSearch().setSize(0).get());
|
||||||
SearchPhaseExecutionException.class,
|
|
||||||
() -> client().prepareSearch().setSize(0).get()
|
|
||||||
);
|
|
||||||
assertThat(ex.getDetailedMessage(), containsString("Search rejected due to missing shard"));
|
assertThat(ex.getDetailedMessage(), containsString("Search rejected due to missing shard"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class SearchWhileRelocatingIT extends ESIntegTestCase {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
indexRandom(true, indexBuilders.toArray(new IndexRequestBuilder[indexBuilders.size()]));
|
indexRandom(true, indexBuilders.toArray(new IndexRequestBuilder[indexBuilders.size()]));
|
||||||
assertHitCount(client().prepareSearch(), (numDocs));
|
assertHitCount(prepareSearch(), (numDocs));
|
||||||
final int numIters = scaledRandomIntBetween(5, 20);
|
final int numIters = scaledRandomIntBetween(5, 20);
|
||||||
for (int i = 0; i < numIters; i++) {
|
for (int i = 0; i < numIters; i++) {
|
||||||
final AtomicBoolean stop = new AtomicBoolean(false);
|
final AtomicBoolean stop = new AtomicBoolean(false);
|
||||||
|
@ -74,7 +74,7 @@ public class SearchWhileRelocatingIT extends ESIntegTestCase {
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
while (stop.get() == false) {
|
while (stop.get() == false) {
|
||||||
SearchResponse sr = client().prepareSearch().setSize(numDocs).get();
|
SearchResponse sr = prepareSearch().setSize(numDocs).get();
|
||||||
if (sr.getHits().getTotalHits().value != numDocs) {
|
if (sr.getHits().getTotalHits().value != numDocs) {
|
||||||
// if we did not search all shards but had no serious failures that is potentially fine
|
// if we did not search all shards but had no serious failures that is potentially fine
|
||||||
// if only the hit-count is wrong. this can happen if the cluster-state is behind when the
|
// if only the hit-count is wrong. this can happen if the cluster-state is behind when the
|
||||||
|
@ -134,7 +134,7 @@ public class SearchWhileRelocatingIT extends ESIntegTestCase {
|
||||||
if (nonCriticalExceptions.isEmpty() == false) {
|
if (nonCriticalExceptions.isEmpty() == false) {
|
||||||
logger.info("non-critical exceptions: {}", nonCriticalExceptions);
|
logger.info("non-critical exceptions: {}", nonCriticalExceptions);
|
||||||
for (int j = 0; j < 10; j++) {
|
for (int j = 0; j < 10; j++) {
|
||||||
assertHitCount(client().prepareSearch(), numDocs);
|
assertHitCount(prepareSearch(), numDocs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,8 +131,7 @@ public class SearchWithRandomExceptionsIT extends ESIntegTestCase {
|
||||||
int docToQuery = between(0, numDocs - 1);
|
int docToQuery = between(0, numDocs - 1);
|
||||||
int expectedResults = added[docToQuery] ? 1 : 0;
|
int expectedResults = added[docToQuery] ? 1 : 0;
|
||||||
logger.info("Searching for [test:{}]", English.intToEnglish(docToQuery));
|
logger.info("Searching for [test:{}]", English.intToEnglish(docToQuery));
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(QueryBuilders.matchQuery("test", English.intToEnglish(docToQuery)))
|
||||||
.setQuery(QueryBuilders.matchQuery("test", English.intToEnglish(docToQuery)))
|
|
||||||
.setSize(expectedResults)
|
.setSize(expectedResults)
|
||||||
.get();
|
.get();
|
||||||
logger.info("Successful shards: [{}] numShards: [{}]", searchResponse.getSuccessfulShards(), test.numPrimaries);
|
logger.info("Successful shards: [{}] numShards: [{}]", searchResponse.getSuccessfulShards(), test.numPrimaries);
|
||||||
|
@ -140,8 +139,7 @@ public class SearchWithRandomExceptionsIT extends ESIntegTestCase {
|
||||||
assertResultsAndLogOnFailure(expectedResults, searchResponse);
|
assertResultsAndLogOnFailure(expectedResults, searchResponse);
|
||||||
}
|
}
|
||||||
// check match all
|
// check match all
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(QueryBuilders.matchAllQuery())
|
||||||
.setQuery(QueryBuilders.matchAllQuery())
|
|
||||||
.setSize(numCreated)
|
.setSize(numCreated)
|
||||||
.addSort("_id", SortOrder.ASC)
|
.addSort("_id", SortOrder.ASC)
|
||||||
.get();
|
.get();
|
||||||
|
|
|
@ -154,8 +154,7 @@ public class SearchWithRandomIOExceptionsIT extends ESIntegTestCase {
|
||||||
int docToQuery = between(0, numDocs - 1);
|
int docToQuery = between(0, numDocs - 1);
|
||||||
int expectedResults = added[docToQuery] ? 1 : 0;
|
int expectedResults = added[docToQuery] ? 1 : 0;
|
||||||
logger.info("Searching for [test:{}]", English.intToEnglish(docToQuery));
|
logger.info("Searching for [test:{}]", English.intToEnglish(docToQuery));
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(QueryBuilders.matchQuery("test", English.intToEnglish(docToQuery)))
|
||||||
.setQuery(QueryBuilders.matchQuery("test", English.intToEnglish(docToQuery)))
|
|
||||||
.setSize(expectedResults)
|
.setSize(expectedResults)
|
||||||
.get();
|
.get();
|
||||||
logger.info("Successful shards: [{}] numShards: [{}]", searchResponse.getSuccessfulShards(), numShards.numPrimaries);
|
logger.info("Successful shards: [{}] numShards: [{}]", searchResponse.getSuccessfulShards(), numShards.numPrimaries);
|
||||||
|
@ -163,8 +162,7 @@ public class SearchWithRandomIOExceptionsIT extends ESIntegTestCase {
|
||||||
assertResultsAndLogOnFailure(expectedResults, searchResponse);
|
assertResultsAndLogOnFailure(expectedResults, searchResponse);
|
||||||
}
|
}
|
||||||
// check match all
|
// check match all
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(QueryBuilders.matchAllQuery())
|
||||||
.setQuery(QueryBuilders.matchAllQuery())
|
|
||||||
.setSize(numCreated + numInitialDocs)
|
.setSize(numCreated + numInitialDocs)
|
||||||
.addSort("_uid", SortOrder.ASC)
|
.addSort("_uid", SortOrder.ASC)
|
||||||
.get();
|
.get();
|
||||||
|
@ -192,7 +190,7 @@ public class SearchWithRandomIOExceptionsIT extends ESIntegTestCase {
|
||||||
indicesAdmin().prepareClose("test").execute().get();
|
indicesAdmin().prepareClose("test").execute().get();
|
||||||
indicesAdmin().prepareOpen("test").execute().get();
|
indicesAdmin().prepareOpen("test").execute().get();
|
||||||
ensureGreen();
|
ensureGreen();
|
||||||
assertHitCountAndNoFailures(client().prepareSearch().setQuery(QueryBuilders.matchQuery("test", "init")), numInitialDocs);
|
assertHitCountAndNoFailures(prepareSearch().setQuery(QueryBuilders.matchQuery("test", "init")), numInitialDocs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,9 +72,9 @@ public class FetchSubPhasePluginIT extends ESIntegTestCase {
|
||||||
|
|
||||||
indicesAdmin().prepareRefresh().get();
|
indicesAdmin().prepareRefresh().get();
|
||||||
|
|
||||||
SearchResponse response = client().prepareSearch()
|
SearchResponse response = prepareSearch().setSource(
|
||||||
.setSource(new SearchSourceBuilder().ext(Collections.singletonList(new TermVectorsFetchBuilder("test"))))
|
new SearchSourceBuilder().ext(Collections.singletonList(new TermVectorsFetchBuilder("test")))
|
||||||
.get();
|
).get();
|
||||||
assertNoFailures(response);
|
assertNoFailures(response);
|
||||||
assertThat(
|
assertThat(
|
||||||
((Map<String, Integer>) response.getHits().getAt(0).field("term_vectors_fetch").getValues().get(0)).get("i"),
|
((Map<String, Integer>) response.getHits().getAt(0).field("term_vectors_fetch").getValues().get(0)).get("i"),
|
||||||
|
|
|
@ -812,13 +812,11 @@ public class InnerHitsIT extends ESIntegTestCase {
|
||||||
|
|
||||||
// the field name (comments.message) used for source filtering should be the same as when using that field for
|
// the field name (comments.message) used for source filtering should be the same as when using that field for
|
||||||
// other features (like in the query dsl or aggs) in order for consistency:
|
// other features (like in the query dsl or aggs) in order for consistency:
|
||||||
SearchResponse response = client().prepareSearch()
|
SearchResponse response = prepareSearch().setQuery(
|
||||||
.setQuery(
|
nestedQuery("comments", matchQuery("comments.message", "fox"), ScoreMode.None).innerHit(
|
||||||
nestedQuery("comments", matchQuery("comments.message", "fox"), ScoreMode.None).innerHit(
|
new InnerHitBuilder().setFetchSourceContext(FetchSourceContext.of(true, new String[] { "comments.message" }, null))
|
||||||
new InnerHitBuilder().setFetchSourceContext(FetchSourceContext.of(true, new String[] { "comments.message" }, null))
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
.get();
|
).get();
|
||||||
assertNoFailures(response);
|
assertNoFailures(response);
|
||||||
assertHitCount(response, 1);
|
assertHitCount(response, 1);
|
||||||
|
|
||||||
|
@ -834,9 +832,9 @@ public class InnerHitsIT extends ESIntegTestCase {
|
||||||
equalTo("fox ate rabbit x y z")
|
equalTo("fox ate rabbit x y z")
|
||||||
);
|
);
|
||||||
|
|
||||||
response = client().prepareSearch()
|
response = prepareSearch().setQuery(
|
||||||
.setQuery(nestedQuery("comments", matchQuery("comments.message", "fox"), ScoreMode.None).innerHit(new InnerHitBuilder()))
|
nestedQuery("comments", matchQuery("comments.message", "fox"), ScoreMode.None).innerHit(new InnerHitBuilder())
|
||||||
.get();
|
).get();
|
||||||
assertNoFailures(response);
|
assertNoFailures(response);
|
||||||
assertHitCount(response, 1);
|
assertHitCount(response, 1);
|
||||||
|
|
||||||
|
@ -854,23 +852,18 @@ public class InnerHitsIT extends ESIntegTestCase {
|
||||||
|
|
||||||
// Source filter on a field that does not exist inside the nested document and just check that we do not fail and
|
// Source filter on a field that does not exist inside the nested document and just check that we do not fail and
|
||||||
// return an empty _source:
|
// return an empty _source:
|
||||||
response = client().prepareSearch()
|
response = prepareSearch().setQuery(
|
||||||
.setQuery(
|
nestedQuery("comments", matchQuery("comments.message", "away"), ScoreMode.None).innerHit(
|
||||||
nestedQuery("comments", matchQuery("comments.message", "away"), ScoreMode.None).innerHit(
|
new InnerHitBuilder().setFetchSourceContext(FetchSourceContext.of(true, new String[] { "comments.missing_field" }, null))
|
||||||
new InnerHitBuilder().setFetchSourceContext(
|
|
||||||
FetchSourceContext.of(true, new String[] { "comments.missing_field" }, null)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
.get();
|
).get();
|
||||||
assertNoFailures(response);
|
assertNoFailures(response);
|
||||||
assertHitCount(response, 1);
|
assertHitCount(response, 1);
|
||||||
assertThat(response.getHits().getAt(0).getInnerHits().get("comments").getTotalHits().value, equalTo(1L));
|
assertThat(response.getHits().getAt(0).getInnerHits().get("comments").getTotalHits().value, equalTo(1L));
|
||||||
assertThat(response.getHits().getAt(0).getInnerHits().get("comments").getAt(0).getSourceAsMap().size(), equalTo(0));
|
assertThat(response.getHits().getAt(0).getInnerHits().get("comments").getAt(0).getSourceAsMap().size(), equalTo(0));
|
||||||
|
|
||||||
// Check that inner hits contain _source even when it's disabled on the root request.
|
// Check that inner hits contain _source even when it's disabled on the root request.
|
||||||
response = client().prepareSearch()
|
response = prepareSearch().setFetchSource(false)
|
||||||
.setFetchSource(false)
|
|
||||||
.setQuery(nestedQuery("comments", matchQuery("comments.message", "fox"), ScoreMode.None).innerHit(new InnerHitBuilder()))
|
.setQuery(nestedQuery("comments", matchQuery("comments.message", "fox"), ScoreMode.None).innerHit(new InnerHitBuilder()))
|
||||||
.get();
|
.get();
|
||||||
assertNoFailures(response);
|
assertNoFailures(response);
|
||||||
|
@ -887,13 +880,12 @@ public class InnerHitsIT extends ESIntegTestCase {
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
assertSearchHitsWithoutFailures(
|
assertSearchHitsWithoutFailures(
|
||||||
client().prepareSearch("index1", "index2")
|
prepareSearch("index1", "index2").setQuery(
|
||||||
.setQuery(
|
boolQuery().should(
|
||||||
boolQuery().should(
|
nestedQuery("nested_type", matchAllQuery(), ScoreMode.None).ignoreUnmapped(true)
|
||||||
nestedQuery("nested_type", matchAllQuery(), ScoreMode.None).ignoreUnmapped(true)
|
.innerHit(new InnerHitBuilder().setIgnoreUnmapped(true))
|
||||||
.innerHit(new InnerHitBuilder().setIgnoreUnmapped(true))
|
).should(termQuery("key", "value"))
|
||||||
).should(termQuery("key", "value"))
|
),
|
||||||
),
|
|
||||||
"1",
|
"1",
|
||||||
"3"
|
"3"
|
||||||
);
|
);
|
||||||
|
|
|
@ -46,15 +46,12 @@ public class MatchedQueriesIT extends ESIntegTestCase {
|
||||||
client().prepareIndex("test").setId("3").setSource("name", "test3", "number", 3).get();
|
client().prepareIndex("test").setId("3").setSource("name", "test3", "number", 3).get();
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(
|
||||||
.setQuery(
|
boolQuery().must(matchAllQuery())
|
||||||
boolQuery().must(matchAllQuery())
|
.filter(
|
||||||
.filter(
|
boolQuery().should(rangeQuery("number").lt(2).queryName("test1")).should(rangeQuery("number").gte(2).queryName("test2"))
|
||||||
boolQuery().should(rangeQuery("number").lt(2).queryName("test1"))
|
)
|
||||||
.should(rangeQuery("number").gte(2).queryName("test2"))
|
).get();
|
||||||
)
|
|
||||||
)
|
|
||||||
.get();
|
|
||||||
assertHitCount(searchResponse, 3L);
|
assertHitCount(searchResponse, 3L);
|
||||||
for (SearchHit hit : searchResponse.getHits()) {
|
for (SearchHit hit : searchResponse.getHits()) {
|
||||||
if (hit.getId().equals("3") || hit.getId().equals("2")) {
|
if (hit.getId().equals("3") || hit.getId().equals("2")) {
|
||||||
|
@ -70,11 +67,9 @@ public class MatchedQueriesIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(
|
||||||
.setQuery(
|
boolQuery().should(rangeQuery("number").lte(2).queryName("test1")).should(rangeQuery("number").gt(2).queryName("test2"))
|
||||||
boolQuery().should(rangeQuery("number").lte(2).queryName("test1")).should(rangeQuery("number").gt(2).queryName("test2"))
|
).get();
|
||||||
)
|
|
||||||
.get();
|
|
||||||
assertHitCount(searchResponse, 3L);
|
assertHitCount(searchResponse, 3L);
|
||||||
for (SearchHit hit : searchResponse.getHits()) {
|
for (SearchHit hit : searchResponse.getHits()) {
|
||||||
if (hit.getId().equals("1") || hit.getId().equals("2")) {
|
if (hit.getId().equals("1") || hit.getId().equals("2")) {
|
||||||
|
@ -100,8 +95,7 @@ public class MatchedQueriesIT extends ESIntegTestCase {
|
||||||
client().prepareIndex("test").setId("3").setSource("name", "test").get();
|
client().prepareIndex("test").setId("3").setSource("name", "test").get();
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.setPostFilter(
|
.setPostFilter(
|
||||||
boolQuery().should(termQuery("name", "test").queryName("name")).should(termQuery("title", "title1").queryName("title"))
|
boolQuery().should(termQuery("name", "test").queryName("name")).should(termQuery("title", "title1").queryName("title"))
|
||||||
)
|
)
|
||||||
|
@ -123,8 +117,7 @@ public class MatchedQueriesIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.setPostFilter(
|
.setPostFilter(
|
||||||
boolQuery().should(termQuery("name", "test").queryName("name")).should(termQuery("title", "title1").queryName("title"))
|
boolQuery().should(termQuery("name", "test").queryName("name")).should(termQuery("title", "title1").queryName("title"))
|
||||||
)
|
)
|
||||||
|
@ -157,10 +150,9 @@ public class MatchedQueriesIT extends ESIntegTestCase {
|
||||||
client().prepareIndex("test").setId("3").setSource("name", "test", "title", "title3").get();
|
client().prepareIndex("test").setId("3").setSource("name", "test", "title", "title3").get();
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(
|
||||||
.setQuery(boolQuery().must(matchAllQuery()).filter(termsQuery("title", "title1", "title2", "title3").queryName("title")))
|
boolQuery().must(matchAllQuery()).filter(termsQuery("title", "title1", "title2", "title3").queryName("title"))
|
||||||
.setPostFilter(termQuery("name", "test").queryName("name"))
|
).setPostFilter(termQuery("name", "test").queryName("name")).get();
|
||||||
.get();
|
|
||||||
assertHitCount(searchResponse, 3L);
|
assertHitCount(searchResponse, 3L);
|
||||||
for (SearchHit hit : searchResponse.getHits()) {
|
for (SearchHit hit : searchResponse.getHits()) {
|
||||||
if (hit.getId().equals("1") || hit.getId().equals("2") || hit.getId().equals("3")) {
|
if (hit.getId().equals("1") || hit.getId().equals("2") || hit.getId().equals("3")) {
|
||||||
|
@ -174,8 +166,7 @@ public class MatchedQueriesIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(termsQuery("title", "title1", "title2", "title3").queryName("title"))
|
||||||
.setQuery(termsQuery("title", "title1", "title2", "title3").queryName("title"))
|
|
||||||
.setPostFilter(matchQuery("name", "test").queryName("name"))
|
.setPostFilter(matchQuery("name", "test").queryName("name"))
|
||||||
.get();
|
.get();
|
||||||
assertHitCount(searchResponse, 3L);
|
assertHitCount(searchResponse, 3L);
|
||||||
|
@ -199,9 +190,7 @@ public class MatchedQueriesIT extends ESIntegTestCase {
|
||||||
client().prepareIndex("test1").setId("1").setSource("title", "title1").get();
|
client().prepareIndex("test1").setId("1").setSource("title", "title1").get();
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(QueryBuilders.regexpQuery("title", "title1").queryName("regex")).get();
|
||||||
.setQuery(QueryBuilders.regexpQuery("title", "title1").queryName("regex"))
|
|
||||||
.get();
|
|
||||||
assertHitCount(searchResponse, 1L);
|
assertHitCount(searchResponse, 1L);
|
||||||
|
|
||||||
for (SearchHit hit : searchResponse.getHits()) {
|
for (SearchHit hit : searchResponse.getHits()) {
|
||||||
|
@ -222,9 +211,7 @@ public class MatchedQueriesIT extends ESIntegTestCase {
|
||||||
client().prepareIndex("test1").setId("1").setSource("title", "title1").get();
|
client().prepareIndex("test1").setId("1").setSource("title", "title1").get();
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(QueryBuilders.prefixQuery("title", "title").queryName("prefix")).get();
|
||||||
.setQuery(QueryBuilders.prefixQuery("title", "title").queryName("prefix"))
|
|
||||||
.get();
|
|
||||||
assertHitCount(searchResponse, 1L);
|
assertHitCount(searchResponse, 1L);
|
||||||
|
|
||||||
for (SearchHit hit : searchResponse.getHits()) {
|
for (SearchHit hit : searchResponse.getHits()) {
|
||||||
|
@ -245,9 +232,7 @@ public class MatchedQueriesIT extends ESIntegTestCase {
|
||||||
client().prepareIndex("test1").setId("1").setSource("title", "title1").get();
|
client().prepareIndex("test1").setId("1").setSource("title", "title1").get();
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(QueryBuilders.fuzzyQuery("title", "titel1").queryName("fuzzy")).get();
|
||||||
.setQuery(QueryBuilders.fuzzyQuery("title", "titel1").queryName("fuzzy"))
|
|
||||||
.get();
|
|
||||||
assertHitCount(searchResponse, 1L);
|
assertHitCount(searchResponse, 1L);
|
||||||
|
|
||||||
for (SearchHit hit : searchResponse.getHits()) {
|
for (SearchHit hit : searchResponse.getHits()) {
|
||||||
|
@ -268,9 +253,7 @@ public class MatchedQueriesIT extends ESIntegTestCase {
|
||||||
client().prepareIndex("test1").setId("1").setSource("title", "title1").get();
|
client().prepareIndex("test1").setId("1").setSource("title", "title1").get();
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(QueryBuilders.wildcardQuery("title", "titl*").queryName("wildcard")).get();
|
||||||
.setQuery(QueryBuilders.wildcardQuery("title", "titl*").queryName("wildcard"))
|
|
||||||
.get();
|
|
||||||
assertHitCount(searchResponse, 1L);
|
assertHitCount(searchResponse, 1L);
|
||||||
|
|
||||||
for (SearchHit hit : searchResponse.getHits()) {
|
for (SearchHit hit : searchResponse.getHits()) {
|
||||||
|
@ -291,9 +274,9 @@ public class MatchedQueriesIT extends ESIntegTestCase {
|
||||||
client().prepareIndex("test1").setId("1").setSource("title", "title1 title2").get();
|
client().prepareIndex("test1").setId("1").setSource("title", "title1 title2").get();
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(
|
||||||
.setQuery(QueryBuilders.spanFirstQuery(QueryBuilders.spanTermQuery("title", "title1"), 10).queryName("span"))
|
QueryBuilders.spanFirstQuery(QueryBuilders.spanTermQuery("title", "title1"), 10).queryName("span")
|
||||||
.get();
|
).get();
|
||||||
assertHitCount(searchResponse, 1L);
|
assertHitCount(searchResponse, 1L);
|
||||||
|
|
||||||
for (SearchHit hit : searchResponse.getHits()) {
|
for (SearchHit hit : searchResponse.getHits()) {
|
||||||
|
@ -321,13 +304,11 @@ public class MatchedQueriesIT extends ESIntegTestCase {
|
||||||
// Execute search at least two times to load it in cache
|
// Execute search at least two times to load it in cache
|
||||||
int iter = scaledRandomIntBetween(2, 10);
|
int iter = scaledRandomIntBetween(2, 10);
|
||||||
for (int i = 0; i < iter; i++) {
|
for (int i = 0; i < iter; i++) {
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(
|
||||||
.setQuery(
|
boolQuery().minimumShouldMatch(1)
|
||||||
boolQuery().minimumShouldMatch(1)
|
.should(queryStringQuery("dolor").queryName("dolor"))
|
||||||
.should(queryStringQuery("dolor").queryName("dolor"))
|
.should(queryStringQuery("elit").queryName("elit"))
|
||||||
.should(queryStringQuery("elit").queryName("elit"))
|
).get();
|
||||||
)
|
|
||||||
.get();
|
|
||||||
|
|
||||||
assertHitCount(searchResponse, 2L);
|
assertHitCount(searchResponse, 2L);
|
||||||
for (SearchHit hit : searchResponse.getHits()) {
|
for (SearchHit hit : searchResponse.getHits()) {
|
||||||
|
@ -359,7 +340,7 @@ public class MatchedQueriesIT extends ESIntegTestCase {
|
||||||
BytesReference termBytes = XContentHelper.toXContent(termQueryBuilder, XContentType.JSON, false);
|
BytesReference termBytes = XContentHelper.toXContent(termQueryBuilder, XContentType.JSON, false);
|
||||||
QueryBuilder[] queries = new QueryBuilder[] { wrapperQuery(matchBytes), constantScoreQuery(wrapperQuery(termBytes)) };
|
QueryBuilder[] queries = new QueryBuilder[] { wrapperQuery(matchBytes), constantScoreQuery(wrapperQuery(termBytes)) };
|
||||||
for (QueryBuilder query : queries) {
|
for (QueryBuilder query : queries) {
|
||||||
SearchResponse searchResponse = client().prepareSearch().setQuery(query).get();
|
SearchResponse searchResponse = prepareSearch().setQuery(query).get();
|
||||||
assertHitCount(searchResponse, 1L);
|
assertHitCount(searchResponse, 1L);
|
||||||
SearchHit hit = searchResponse.getHits().getAt(0);
|
SearchHit hit = searchResponse.getHits().getAt(0);
|
||||||
assertThat(hit.getMatchedQueriesAndScores().size(), equalTo(1));
|
assertThat(hit.getMatchedQueriesAndScores().size(), equalTo(1));
|
||||||
|
@ -376,8 +357,7 @@ public class MatchedQueriesIT extends ESIntegTestCase {
|
||||||
client().prepareIndex("test").setId("2").setSource("content", "hello you").get();
|
client().prepareIndex("test").setId("2").setSource("content", "hello you").get();
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(new MatchAllQueryBuilder().queryName("all"))
|
||||||
.setQuery(new MatchAllQueryBuilder().queryName("all"))
|
|
||||||
.setRescorer(
|
.setRescorer(
|
||||||
new QueryRescorerBuilder(new MatchPhraseQueryBuilder("content", "hello you").boost(10).queryName("rescore_phrase"))
|
new QueryRescorerBuilder(new MatchPhraseQueryBuilder("content", "hello you").boost(10).queryName("rescore_phrase"))
|
||||||
)
|
)
|
||||||
|
|
|
@ -189,33 +189,32 @@ public class SearchFieldsIT extends ESIntegTestCase {
|
||||||
|
|
||||||
indicesAdmin().prepareRefresh().get();
|
indicesAdmin().prepareRefresh().get();
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch().setQuery(matchAllQuery()).addStoredField("field1").get();
|
SearchResponse searchResponse = prepareSearch().setQuery(matchAllQuery()).addStoredField("field1").get();
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
||||||
assertThat(searchResponse.getHits().getHits().length, equalTo(1));
|
assertThat(searchResponse.getHits().getHits().length, equalTo(1));
|
||||||
assertThat(searchResponse.getHits().getAt(0).getFields().size(), equalTo(1));
|
assertThat(searchResponse.getHits().getAt(0).getFields().size(), equalTo(1));
|
||||||
assertThat(searchResponse.getHits().getAt(0).getFields().get("field1").getValue().toString(), equalTo("value1"));
|
assertThat(searchResponse.getHits().getAt(0).getFields().get("field1").getValue().toString(), equalTo("value1"));
|
||||||
|
|
||||||
// field2 is not stored, check that it is not extracted from source.
|
// field2 is not stored, check that it is not extracted from source.
|
||||||
searchResponse = client().prepareSearch().setQuery(matchAllQuery()).addStoredField("field2").get();
|
searchResponse = prepareSearch().setQuery(matchAllQuery()).addStoredField("field2").get();
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
||||||
assertThat(searchResponse.getHits().getHits().length, equalTo(1));
|
assertThat(searchResponse.getHits().getHits().length, equalTo(1));
|
||||||
assertThat(searchResponse.getHits().getAt(0).getFields().size(), equalTo(0));
|
assertThat(searchResponse.getHits().getAt(0).getFields().size(), equalTo(0));
|
||||||
assertThat(searchResponse.getHits().getAt(0).getFields().get("field2"), nullValue());
|
assertThat(searchResponse.getHits().getAt(0).getFields().get("field2"), nullValue());
|
||||||
|
|
||||||
searchResponse = client().prepareSearch().setQuery(matchAllQuery()).addStoredField("field3").get();
|
searchResponse = prepareSearch().setQuery(matchAllQuery()).addStoredField("field3").get();
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
||||||
assertThat(searchResponse.getHits().getHits().length, equalTo(1));
|
assertThat(searchResponse.getHits().getHits().length, equalTo(1));
|
||||||
assertThat(searchResponse.getHits().getAt(0).getFields().size(), equalTo(1));
|
assertThat(searchResponse.getHits().getAt(0).getFields().size(), equalTo(1));
|
||||||
assertThat(searchResponse.getHits().getAt(0).getFields().get("field3").getValue().toString(), equalTo("value3"));
|
assertThat(searchResponse.getHits().getAt(0).getFields().get("field3").getValue().toString(), equalTo("value3"));
|
||||||
|
|
||||||
searchResponse = client().prepareSearch().setQuery(matchAllQuery()).addStoredField("*3").get();
|
searchResponse = prepareSearch().setQuery(matchAllQuery()).addStoredField("*3").get();
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
||||||
assertThat(searchResponse.getHits().getHits().length, equalTo(1));
|
assertThat(searchResponse.getHits().getHits().length, equalTo(1));
|
||||||
assertThat(searchResponse.getHits().getAt(0).getFields().size(), equalTo(1));
|
assertThat(searchResponse.getHits().getAt(0).getFields().size(), equalTo(1));
|
||||||
assertThat(searchResponse.getHits().getAt(0).getFields().get("field3").getValue().toString(), equalTo("value3"));
|
assertThat(searchResponse.getHits().getAt(0).getFields().get("field3").getValue().toString(), equalTo("value3"));
|
||||||
|
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addStoredField("*3")
|
.addStoredField("*3")
|
||||||
.addStoredField("field1")
|
.addStoredField("field1")
|
||||||
.addStoredField("field2")
|
.addStoredField("field2")
|
||||||
|
@ -226,20 +225,20 @@ public class SearchFieldsIT extends ESIntegTestCase {
|
||||||
assertThat(searchResponse.getHits().getAt(0).getFields().get("field3").getValue().toString(), equalTo("value3"));
|
assertThat(searchResponse.getHits().getAt(0).getFields().get("field3").getValue().toString(), equalTo("value3"));
|
||||||
assertThat(searchResponse.getHits().getAt(0).getFields().get("field1").getValue().toString(), equalTo("value1"));
|
assertThat(searchResponse.getHits().getAt(0).getFields().get("field1").getValue().toString(), equalTo("value1"));
|
||||||
|
|
||||||
searchResponse = client().prepareSearch().setQuery(matchAllQuery()).addStoredField("field*").get();
|
searchResponse = prepareSearch().setQuery(matchAllQuery()).addStoredField("field*").get();
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
||||||
assertThat(searchResponse.getHits().getHits().length, equalTo(1));
|
assertThat(searchResponse.getHits().getHits().length, equalTo(1));
|
||||||
assertThat(searchResponse.getHits().getAt(0).getFields().size(), equalTo(2));
|
assertThat(searchResponse.getHits().getAt(0).getFields().size(), equalTo(2));
|
||||||
assertThat(searchResponse.getHits().getAt(0).getFields().get("field3").getValue().toString(), equalTo("value3"));
|
assertThat(searchResponse.getHits().getAt(0).getFields().get("field3").getValue().toString(), equalTo("value3"));
|
||||||
assertThat(searchResponse.getHits().getAt(0).getFields().get("field1").getValue().toString(), equalTo("value1"));
|
assertThat(searchResponse.getHits().getAt(0).getFields().get("field1").getValue().toString(), equalTo("value1"));
|
||||||
|
|
||||||
searchResponse = client().prepareSearch().setQuery(matchAllQuery()).addStoredField("f*3").get();
|
searchResponse = prepareSearch().setQuery(matchAllQuery()).addStoredField("f*3").get();
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
||||||
assertThat(searchResponse.getHits().getHits().length, equalTo(1));
|
assertThat(searchResponse.getHits().getHits().length, equalTo(1));
|
||||||
assertThat(searchResponse.getHits().getAt(0).getFields().size(), equalTo(1));
|
assertThat(searchResponse.getHits().getAt(0).getFields().size(), equalTo(1));
|
||||||
assertThat(searchResponse.getHits().getAt(0).getFields().get("field3").getValue().toString(), equalTo("value3"));
|
assertThat(searchResponse.getHits().getAt(0).getFields().get("field3").getValue().toString(), equalTo("value3"));
|
||||||
|
|
||||||
searchResponse = client().prepareSearch().setQuery(matchAllQuery()).addStoredField("*").get();
|
searchResponse = prepareSearch().setQuery(matchAllQuery()).addStoredField("*").get();
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
||||||
assertThat(searchResponse.getHits().getHits().length, equalTo(1));
|
assertThat(searchResponse.getHits().getHits().length, equalTo(1));
|
||||||
assertThat(searchResponse.getHits().getAt(0).getSourceAsMap(), nullValue());
|
assertThat(searchResponse.getHits().getAt(0).getSourceAsMap(), nullValue());
|
||||||
|
@ -247,7 +246,7 @@ public class SearchFieldsIT extends ESIntegTestCase {
|
||||||
assertThat(searchResponse.getHits().getAt(0).getFields().get("field1").getValue().toString(), equalTo("value1"));
|
assertThat(searchResponse.getHits().getAt(0).getFields().get("field1").getValue().toString(), equalTo("value1"));
|
||||||
assertThat(searchResponse.getHits().getAt(0).getFields().get("field3").getValue().toString(), equalTo("value3"));
|
assertThat(searchResponse.getHits().getAt(0).getFields().get("field3").getValue().toString(), equalTo("value3"));
|
||||||
|
|
||||||
searchResponse = client().prepareSearch().setQuery(matchAllQuery()).addStoredField("*").addStoredField("_source").get();
|
searchResponse = prepareSearch().setQuery(matchAllQuery()).addStoredField("*").addStoredField("_source").get();
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
||||||
assertThat(searchResponse.getHits().getHits().length, equalTo(1));
|
assertThat(searchResponse.getHits().getHits().length, equalTo(1));
|
||||||
assertThat(searchResponse.getHits().getAt(0).getSourceAsMap(), notNullValue());
|
assertThat(searchResponse.getHits().getAt(0).getSourceAsMap(), notNullValue());
|
||||||
|
@ -298,8 +297,7 @@ public class SearchFieldsIT extends ESIntegTestCase {
|
||||||
indicesAdmin().refresh(new RefreshRequest()).actionGet();
|
indicesAdmin().refresh(new RefreshRequest()).actionGet();
|
||||||
|
|
||||||
logger.info("running doc['num1'].value");
|
logger.info("running doc['num1'].value");
|
||||||
SearchResponse response = client().prepareSearch()
|
SearchResponse response = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addSort("num1", SortOrder.ASC)
|
.addSort("num1", SortOrder.ASC)
|
||||||
.addScriptField("sNum1", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc['num1'].value", Collections.emptyMap()))
|
.addScriptField("sNum1", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc['num1'].value", Collections.emptyMap()))
|
||||||
.addScriptField(
|
.addScriptField(
|
||||||
|
@ -336,8 +334,7 @@ public class SearchFieldsIT extends ESIntegTestCase {
|
||||||
assertThat(response.getHits().getAt(2).getFields().get("date1").getValues().get(0), equalTo(120000L));
|
assertThat(response.getHits().getAt(2).getFields().get("date1").getValues().get(0), equalTo(120000L));
|
||||||
|
|
||||||
logger.info("running doc['num1'].value * factor");
|
logger.info("running doc['num1'].value * factor");
|
||||||
response = client().prepareSearch()
|
response = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addSort("num1", SortOrder.ASC)
|
.addSort("num1", SortOrder.ASC)
|
||||||
.addScriptField(
|
.addScriptField(
|
||||||
"sNum1",
|
"sNum1",
|
||||||
|
@ -387,8 +384,7 @@ public class SearchFieldsIT extends ESIntegTestCase {
|
||||||
client().prepareIndex("test").setId("2").setSource(jsonBuilder().startObject().field("date", date).endObject())
|
client().prepareIndex("test").setId("2").setSource(jsonBuilder().startObject().field("date", date).endObject())
|
||||||
);
|
);
|
||||||
|
|
||||||
SearchResponse response = client().prepareSearch()
|
SearchResponse response = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addSort("date", SortOrder.ASC)
|
.addSort("date", SortOrder.ASC)
|
||||||
.addScriptField(
|
.addScriptField(
|
||||||
"date1",
|
"date1",
|
||||||
|
@ -428,8 +424,7 @@ public class SearchFieldsIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
indexRandom(true, indexRequestBuilders);
|
indexRandom(true, indexRequestBuilders);
|
||||||
|
|
||||||
SearchResponse response = client().prepareSearch()
|
SearchResponse response = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addSort("num1", SortOrder.ASC)
|
.addSort("num1", SortOrder.ASC)
|
||||||
.setSize(numDocs)
|
.setSize(numDocs)
|
||||||
.addScriptField("id", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_fields._id.value", Collections.emptyMap()))
|
.addScriptField("id", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_fields._id.value", Collections.emptyMap()))
|
||||||
|
@ -472,8 +467,7 @@ public class SearchFieldsIT extends ESIntegTestCase {
|
||||||
.get();
|
.get();
|
||||||
indicesAdmin().refresh(new RefreshRequest()).actionGet();
|
indicesAdmin().refresh(new RefreshRequest()).actionGet();
|
||||||
|
|
||||||
SearchResponse response = client().prepareSearch()
|
SearchResponse response = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addScriptField("s_obj1", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_source.obj1", Collections.emptyMap()))
|
.addScriptField("s_obj1", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_source.obj1", Collections.emptyMap()))
|
||||||
.addScriptField(
|
.addScriptField(
|
||||||
"s_obj1_test",
|
"s_obj1_test",
|
||||||
|
@ -513,8 +507,7 @@ public class SearchFieldsIT extends ESIntegTestCase {
|
||||||
public void testScriptFieldsForNullReturn() throws Exception {
|
public void testScriptFieldsForNullReturn() throws Exception {
|
||||||
client().prepareIndex("test").setId("1").setSource("foo", "bar").setRefreshPolicy("true").get();
|
client().prepareIndex("test").setId("1").setSource("foo", "bar").setRefreshPolicy("true").get();
|
||||||
|
|
||||||
SearchResponse response = client().prepareSearch()
|
SearchResponse response = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addScriptField("test_script_1", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "return null", Collections.emptyMap()))
|
.addScriptField("test_script_1", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "return null", Collections.emptyMap()))
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
|
@ -631,8 +624,7 @@ public class SearchFieldsIT extends ESIntegTestCase {
|
||||||
|
|
||||||
indicesAdmin().prepareRefresh().get();
|
indicesAdmin().prepareRefresh().get();
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addStoredField("byte_field")
|
.addStoredField("byte_field")
|
||||||
.addStoredField("short_field")
|
.addStoredField("short_field")
|
||||||
.addStoredField("integer_field")
|
.addStoredField("integer_field")
|
||||||
|
@ -852,8 +844,7 @@ public class SearchFieldsIT extends ESIntegTestCase {
|
||||||
|
|
||||||
indicesAdmin().prepareRefresh().get();
|
indicesAdmin().prepareRefresh().get();
|
||||||
|
|
||||||
SearchRequestBuilder builder = client().prepareSearch()
|
SearchRequestBuilder builder = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addDocValueField("text_field")
|
.addDocValueField("text_field")
|
||||||
.addDocValueField("keyword_field")
|
.addDocValueField("keyword_field")
|
||||||
.addDocValueField("byte_field")
|
.addDocValueField("byte_field")
|
||||||
|
@ -910,7 +901,7 @@ public class SearchFieldsIT extends ESIntegTestCase {
|
||||||
assertThat(searchResponse.getHits().getAt(0).getFields().get("binary_field").getValues(), equalTo(List.of("KmQ=")));
|
assertThat(searchResponse.getHits().getAt(0).getFields().get("binary_field").getValues(), equalTo(List.of("KmQ=")));
|
||||||
assertThat(searchResponse.getHits().getAt(0).getFields().get("ip_field").getValues(), equalTo(List.of("::1")));
|
assertThat(searchResponse.getHits().getAt(0).getFields().get("ip_field").getValues(), equalTo(List.of("::1")));
|
||||||
|
|
||||||
builder = client().prepareSearch().setQuery(matchAllQuery()).addDocValueField("*field");
|
builder = prepareSearch().setQuery(matchAllQuery()).addDocValueField("*field");
|
||||||
searchResponse = builder.get();
|
searchResponse = builder.get();
|
||||||
|
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
||||||
|
@ -952,8 +943,7 @@ public class SearchFieldsIT extends ESIntegTestCase {
|
||||||
assertThat(searchResponse.getHits().getAt(0).getFields().get("binary_field").getValues(), equalTo(List.of("KmQ=")));
|
assertThat(searchResponse.getHits().getAt(0).getFields().get("binary_field").getValues(), equalTo(List.of("KmQ=")));
|
||||||
assertThat(searchResponse.getHits().getAt(0).getFields().get("ip_field").getValues(), equalTo(List.of("::1")));
|
assertThat(searchResponse.getHits().getAt(0).getFields().get("ip_field").getValues(), equalTo(List.of("::1")));
|
||||||
|
|
||||||
builder = client().prepareSearch()
|
builder = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addDocValueField("byte_field", "#.0")
|
.addDocValueField("byte_field", "#.0")
|
||||||
.addDocValueField("short_field", "#.0")
|
.addDocValueField("short_field", "#.0")
|
||||||
.addDocValueField("integer_field", "#.0")
|
.addDocValueField("integer_field", "#.0")
|
||||||
|
@ -1081,8 +1071,7 @@ public class SearchFieldsIT extends ESIntegTestCase {
|
||||||
indexDoc("test", "1", "text_field", "foo", "date_field", formatter.format(date));
|
indexDoc("test", "1", "text_field", "foo", "date_field", formatter.format(date));
|
||||||
refresh("test");
|
refresh("test");
|
||||||
|
|
||||||
SearchRequestBuilder builder = client().prepareSearch()
|
SearchRequestBuilder builder = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addDocValueField("text_field_alias")
|
.addDocValueField("text_field_alias")
|
||||||
.addDocValueField("date_field_alias")
|
.addDocValueField("date_field_alias")
|
||||||
.addDocValueField("date_field");
|
.addDocValueField("date_field");
|
||||||
|
@ -1144,10 +1133,7 @@ public class SearchFieldsIT extends ESIntegTestCase {
|
||||||
indexDoc("test", "1", "text_field", "foo", "date_field", formatter.format(date));
|
indexDoc("test", "1", "text_field", "foo", "date_field", formatter.format(date));
|
||||||
refresh("test");
|
refresh("test");
|
||||||
|
|
||||||
SearchRequestBuilder builder = client().prepareSearch()
|
SearchRequestBuilder builder = prepareSearch().setQuery(matchAllQuery()).addDocValueField("*alias").addDocValueField("date_field");
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addDocValueField("*alias")
|
|
||||||
.addDocValueField("date_field");
|
|
||||||
SearchResponse searchResponse = builder.get();
|
SearchResponse searchResponse = builder.get();
|
||||||
|
|
||||||
assertNoFailures(searchResponse);
|
assertNoFailures(searchResponse);
|
||||||
|
@ -1199,8 +1185,7 @@ public class SearchFieldsIT extends ESIntegTestCase {
|
||||||
indexDoc("test", "1", "field1", "value1", "field2", "value2");
|
indexDoc("test", "1", "field1", "value1", "field2", "value2");
|
||||||
refresh("test");
|
refresh("test");
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addStoredField("field1-alias")
|
.addStoredField("field1-alias")
|
||||||
.addStoredField("field2-alias")
|
.addStoredField("field2-alias")
|
||||||
.get();
|
.get();
|
||||||
|
@ -1243,7 +1228,7 @@ public class SearchFieldsIT extends ESIntegTestCase {
|
||||||
indexDoc("test", "1", "field1", "value1", "field2", "value2");
|
indexDoc("test", "1", "field1", "value1", "field2", "value2");
|
||||||
refresh("test");
|
refresh("test");
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch().setQuery(matchAllQuery()).addStoredField("field*").get();
|
SearchResponse searchResponse = prepareSearch().setQuery(matchAllQuery()).addStoredField("field*").get();
|
||||||
assertHitCount(searchResponse, 1L);
|
assertHitCount(searchResponse, 1L);
|
||||||
|
|
||||||
SearchHit hit = searchResponse.getHits().getAt(0);
|
SearchHit hit = searchResponse.getHits().getAt(0);
|
||||||
|
|
|
@ -72,8 +72,7 @@ public class QueryRescorerIT extends ESIntegTestCase {
|
||||||
|
|
||||||
int numShards = getNumShards("test").numPrimaries;
|
int numShards = getNumShards("test").numPrimaries;
|
||||||
for (int j = 0; j < iters; j++) {
|
for (int j = 0; j < iters; j++) {
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(QueryBuilders.matchAllQuery())
|
||||||
.setQuery(QueryBuilders.matchAllQuery())
|
|
||||||
.setRescorer(
|
.setRescorer(
|
||||||
new QueryRescorerBuilder(
|
new QueryRescorerBuilder(
|
||||||
functionScoreQuery(matchAllQuery(), ScoreFunctionBuilders.weightFactorFunction(100)).boostMode(
|
functionScoreQuery(matchAllQuery(), ScoreFunctionBuilders.weightFactorFunction(100)).boostMode(
|
||||||
|
@ -122,8 +121,9 @@ public class QueryRescorerIT extends ESIntegTestCase {
|
||||||
.setSource("field1", "quick huge brown", "field2", "the quick lazy huge brown fox jumps over the tree")
|
.setSource("field1", "quick huge brown", "field2", "the quick lazy huge brown fox jumps over the tree")
|
||||||
.get();
|
.get();
|
||||||
refresh();
|
refresh();
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(
|
||||||
.setQuery(QueryBuilders.matchQuery("field1", "the quick brown").operator(Operator.OR))
|
QueryBuilders.matchQuery("field1", "the quick brown").operator(Operator.OR)
|
||||||
|
)
|
||||||
.setRescorer(
|
.setRescorer(
|
||||||
new QueryRescorerBuilder(matchPhraseQuery("field1", "quick brown").slop(2).boost(4.0f)).setRescoreQueryWeight(2),
|
new QueryRescorerBuilder(matchPhraseQuery("field1", "quick brown").slop(2).boost(4.0f)).setRescoreQueryWeight(2),
|
||||||
5
|
5
|
||||||
|
@ -136,8 +136,7 @@ public class QueryRescorerIT extends ESIntegTestCase {
|
||||||
assertThat(searchResponse.getHits().getHits()[1].getId(), equalTo("3"));
|
assertThat(searchResponse.getHits().getHits()[1].getId(), equalTo("3"));
|
||||||
assertThat(searchResponse.getHits().getHits()[2].getId(), equalTo("2"));
|
assertThat(searchResponse.getHits().getHits()[2].getId(), equalTo("2"));
|
||||||
|
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(QueryBuilders.matchQuery("field1", "the quick brown").operator(Operator.OR))
|
||||||
.setQuery(QueryBuilders.matchQuery("field1", "the quick brown").operator(Operator.OR))
|
|
||||||
.setRescorer(new QueryRescorerBuilder(matchPhraseQuery("field1", "the quick brown").slop(3)), 5)
|
.setRescorer(new QueryRescorerBuilder(matchPhraseQuery("field1", "the quick brown").slop(3)), 5)
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
|
@ -146,8 +145,7 @@ public class QueryRescorerIT extends ESIntegTestCase {
|
||||||
assertSecondHit(searchResponse, hasId("2"));
|
assertSecondHit(searchResponse, hasId("2"));
|
||||||
assertThirdHit(searchResponse, hasId("3"));
|
assertThirdHit(searchResponse, hasId("3"));
|
||||||
|
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(QueryBuilders.matchQuery("field1", "the quick brown").operator(Operator.OR))
|
||||||
.setQuery(QueryBuilders.matchQuery("field1", "the quick brown").operator(Operator.OR))
|
|
||||||
.setRescorer(new QueryRescorerBuilder(matchPhraseQuery("field1", "the quick brown")), 5)
|
.setRescorer(new QueryRescorerBuilder(matchPhraseQuery("field1", "the quick brown")), 5)
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
|
@ -191,8 +189,9 @@ public class QueryRescorerIT extends ESIntegTestCase {
|
||||||
client().prepareIndex("test").setId("11").setSource("field1", "2st street boston massachusetts").get();
|
client().prepareIndex("test").setId("11").setSource("field1", "2st street boston massachusetts").get();
|
||||||
client().prepareIndex("test").setId("12").setSource("field1", "3st street boston massachusetts").get();
|
client().prepareIndex("test").setId("12").setSource("field1", "3st street boston massachusetts").get();
|
||||||
indicesAdmin().prepareRefresh("test").get();
|
indicesAdmin().prepareRefresh("test").get();
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(
|
||||||
.setQuery(QueryBuilders.matchQuery("field1", "lexington avenue massachusetts").operator(Operator.OR))
|
QueryBuilders.matchQuery("field1", "lexington avenue massachusetts").operator(Operator.OR)
|
||||||
|
)
|
||||||
.setFrom(0)
|
.setFrom(0)
|
||||||
.setSize(5)
|
.setSize(5)
|
||||||
.setRescorer(
|
.setRescorer(
|
||||||
|
@ -208,8 +207,9 @@ public class QueryRescorerIT extends ESIntegTestCase {
|
||||||
assertSecondHit(searchResponse, hasId("6"));
|
assertSecondHit(searchResponse, hasId("6"));
|
||||||
assertThirdHit(searchResponse, hasId("3"));
|
assertThirdHit(searchResponse, hasId("3"));
|
||||||
|
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(
|
||||||
.setQuery(QueryBuilders.matchQuery("field1", "lexington avenue massachusetts").operator(Operator.OR))
|
QueryBuilders.matchQuery("field1", "lexington avenue massachusetts").operator(Operator.OR)
|
||||||
|
)
|
||||||
.setFrom(0)
|
.setFrom(0)
|
||||||
.setSize(5)
|
.setSize(5)
|
||||||
.setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
|
.setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
|
||||||
|
@ -228,8 +228,9 @@ public class QueryRescorerIT extends ESIntegTestCase {
|
||||||
assertThirdHit(searchResponse, hasId("3"));
|
assertThirdHit(searchResponse, hasId("3"));
|
||||||
|
|
||||||
// Make sure non-zero from works:
|
// Make sure non-zero from works:
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(
|
||||||
.setQuery(QueryBuilders.matchQuery("field1", "lexington avenue massachusetts").operator(Operator.OR))
|
QueryBuilders.matchQuery("field1", "lexington avenue massachusetts").operator(Operator.OR)
|
||||||
|
)
|
||||||
.setFrom(2)
|
.setFrom(2)
|
||||||
.setSize(5)
|
.setSize(5)
|
||||||
.setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
|
.setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
|
||||||
|
@ -271,8 +272,7 @@ public class QueryRescorerIT extends ESIntegTestCase {
|
||||||
client().prepareIndex("test").setId("2").setSource("field1", "lexington avenue boston massachusetts road").get();
|
client().prepareIndex("test").setId("2").setSource("field1", "lexington avenue boston massachusetts road").get();
|
||||||
indicesAdmin().prepareRefresh("test").get();
|
indicesAdmin().prepareRefresh("test").get();
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(QueryBuilders.matchQuery("field1", "massachusetts"))
|
||||||
.setQuery(QueryBuilders.matchQuery("field1", "massachusetts"))
|
|
||||||
.setFrom(0)
|
.setFrom(0)
|
||||||
.setSize(5)
|
.setSize(5)
|
||||||
.get();
|
.get();
|
||||||
|
@ -285,8 +285,7 @@ public class QueryRescorerIT extends ESIntegTestCase {
|
||||||
assertFourthHit(searchResponse, hasId("2"));
|
assertFourthHit(searchResponse, hasId("2"));
|
||||||
|
|
||||||
// Now, rescore only top 2 hits w/ proximity:
|
// Now, rescore only top 2 hits w/ proximity:
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(QueryBuilders.matchQuery("field1", "massachusetts"))
|
||||||
.setQuery(QueryBuilders.matchQuery("field1", "massachusetts"))
|
|
||||||
.setFrom(0)
|
.setFrom(0)
|
||||||
.setSize(5)
|
.setSize(5)
|
||||||
.setRescorer(
|
.setRescorer(
|
||||||
|
@ -305,8 +304,7 @@ public class QueryRescorerIT extends ESIntegTestCase {
|
||||||
assertFourthHit(searchResponse, hasId("2"));
|
assertFourthHit(searchResponse, hasId("2"));
|
||||||
|
|
||||||
// Now, rescore only top 3 hits w/ proximity:
|
// Now, rescore only top 3 hits w/ proximity:
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(QueryBuilders.matchQuery("field1", "massachusetts"))
|
||||||
.setQuery(QueryBuilders.matchQuery("field1", "massachusetts"))
|
|
||||||
.setFrom(0)
|
.setFrom(0)
|
||||||
.setSize(5)
|
.setSize(5)
|
||||||
.setRescorer(
|
.setRescorer(
|
||||||
|
@ -351,8 +349,7 @@ public class QueryRescorerIT extends ESIntegTestCase {
|
||||||
client().prepareIndex("test").setId("2").setSource("field1", "lexington avenue boston massachusetts road").get();
|
client().prepareIndex("test").setId("2").setSource("field1", "lexington avenue boston massachusetts road").get();
|
||||||
indicesAdmin().prepareRefresh("test").get();
|
indicesAdmin().prepareRefresh("test").get();
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(QueryBuilders.matchQuery("field1", "massachusetts").operator(Operator.OR))
|
||||||
.setQuery(QueryBuilders.matchQuery("field1", "massachusetts").operator(Operator.OR))
|
|
||||||
.setFrom(0)
|
.setFrom(0)
|
||||||
.setSize(5)
|
.setSize(5)
|
||||||
.get();
|
.get();
|
||||||
|
@ -365,8 +362,7 @@ public class QueryRescorerIT extends ESIntegTestCase {
|
||||||
assertFourthHit(searchResponse, hasId("2"));
|
assertFourthHit(searchResponse, hasId("2"));
|
||||||
|
|
||||||
// Now, penalizing rescore (nothing matches the rescore query):
|
// Now, penalizing rescore (nothing matches the rescore query):
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(QueryBuilders.matchQuery("field1", "massachusetts").operator(Operator.OR))
|
||||||
.setQuery(QueryBuilders.matchQuery("field1", "massachusetts").operator(Operator.OR))
|
|
||||||
.setFrom(0)
|
.setFrom(0)
|
||||||
.setSize(5)
|
.setSize(5)
|
||||||
.setRescorer(
|
.setRescorer(
|
||||||
|
@ -434,8 +430,7 @@ public class QueryRescorerIT extends ESIntegTestCase {
|
||||||
int rescoreWindow = between(1, 3) * resultSize;
|
int rescoreWindow = between(1, 3) * resultSize;
|
||||||
String intToEnglish = English.intToEnglish(between(0, numDocs - 1));
|
String intToEnglish = English.intToEnglish(between(0, numDocs - 1));
|
||||||
String query = intToEnglish.split(" ")[0];
|
String query = intToEnglish.split(" ")[0];
|
||||||
SearchResponse rescored = client().prepareSearch()
|
SearchResponse rescored = prepareSearch().setSearchType(SearchType.QUERY_THEN_FETCH)
|
||||||
.setSearchType(SearchType.QUERY_THEN_FETCH)
|
|
||||||
.setPreference("test") // ensure we hit the same shards for tie-breaking
|
.setPreference("test") // ensure we hit the same shards for tie-breaking
|
||||||
.setQuery(QueryBuilders.matchQuery("field1", query).operator(Operator.OR))
|
.setQuery(QueryBuilders.matchQuery("field1", query).operator(Operator.OR))
|
||||||
.setFrom(0)
|
.setFrom(0)
|
||||||
|
@ -448,8 +443,7 @@ public class QueryRescorerIT extends ESIntegTestCase {
|
||||||
)
|
)
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
SearchResponse plain = client().prepareSearch()
|
SearchResponse plain = prepareSearch().setSearchType(SearchType.QUERY_THEN_FETCH)
|
||||||
.setSearchType(SearchType.QUERY_THEN_FETCH)
|
|
||||||
.setPreference("test") // ensure we hit the same shards for tie-breaking
|
.setPreference("test") // ensure we hit the same shards for tie-breaking
|
||||||
.setQuery(QueryBuilders.matchQuery("field1", query).operator(Operator.OR))
|
.setQuery(QueryBuilders.matchQuery("field1", query).operator(Operator.OR))
|
||||||
.setFrom(0)
|
.setFrom(0)
|
||||||
|
@ -459,8 +453,7 @@ public class QueryRescorerIT extends ESIntegTestCase {
|
||||||
// check equivalence
|
// check equivalence
|
||||||
assertEquivalent(query, plain, rescored);
|
assertEquivalent(query, plain, rescored);
|
||||||
|
|
||||||
rescored = client().prepareSearch()
|
rescored = prepareSearch().setSearchType(SearchType.QUERY_THEN_FETCH)
|
||||||
.setSearchType(SearchType.QUERY_THEN_FETCH)
|
|
||||||
.setPreference("test") // ensure we hit the same shards for tie-breaking
|
.setPreference("test") // ensure we hit the same shards for tie-breaking
|
||||||
.setQuery(QueryBuilders.matchQuery("field1", query).operator(Operator.OR))
|
.setQuery(QueryBuilders.matchQuery("field1", query).operator(Operator.OR))
|
||||||
.setFrom(0)
|
.setFrom(0)
|
||||||
|
@ -502,8 +495,7 @@ public class QueryRescorerIT extends ESIntegTestCase {
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
{
|
{
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
|
||||||
.setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
|
|
||||||
.setQuery(QueryBuilders.matchQuery("field1", "the quick brown").operator(Operator.OR))
|
.setQuery(QueryBuilders.matchQuery("field1", "the quick brown").operator(Operator.OR))
|
||||||
.setRescorer(
|
.setRescorer(
|
||||||
new QueryRescorerBuilder(matchPhraseQuery("field1", "the quick brown").slop(2).boost(4.0f)).setQueryWeight(0.5f)
|
new QueryRescorerBuilder(matchPhraseQuery("field1", "the quick brown").slop(2).boost(4.0f)).setQueryWeight(0.5f)
|
||||||
|
@ -549,8 +541,7 @@ public class QueryRescorerIT extends ESIntegTestCase {
|
||||||
innerRescoreQuery.setScoreMode(QueryRescoreMode.fromString(scoreModes[innerMode]));
|
innerRescoreQuery.setScoreMode(QueryRescoreMode.fromString(scoreModes[innerMode]));
|
||||||
}
|
}
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
|
||||||
.setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
|
|
||||||
.setQuery(QueryBuilders.matchQuery("field1", "the quick brown").operator(Operator.OR))
|
.setQuery(QueryBuilders.matchQuery("field1", "the quick brown").operator(Operator.OR))
|
||||||
.setRescorer(innerRescoreQuery, 5)
|
.setRescorer(innerRescoreQuery, 5)
|
||||||
.setExplain(true)
|
.setExplain(true)
|
||||||
|
@ -573,8 +564,7 @@ public class QueryRescorerIT extends ESIntegTestCase {
|
||||||
outerRescoreQuery.setScoreMode(QueryRescoreMode.fromString(scoreModes[outerMode]));
|
outerRescoreQuery.setScoreMode(QueryRescoreMode.fromString(scoreModes[outerMode]));
|
||||||
}
|
}
|
||||||
|
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
|
||||||
.setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
|
|
||||||
.setQuery(QueryBuilders.matchQuery("field1", "the quick brown").operator(Operator.OR))
|
.setQuery(QueryBuilders.matchQuery("field1", "the quick brown").operator(Operator.OR))
|
||||||
.addRescorer(innerRescoreQuery, 5)
|
.addRescorer(innerRescoreQuery, 5)
|
||||||
.addRescorer(outerRescoreQuery.windowSize(10))
|
.addRescorer(outerRescoreQuery.windowSize(10))
|
||||||
|
@ -628,8 +618,7 @@ public class QueryRescorerIT extends ESIntegTestCase {
|
||||||
rescoreQuery.setScoreMode(QueryRescoreMode.fromString(scoreMode));
|
rescoreQuery.setScoreMode(QueryRescoreMode.fromString(scoreMode));
|
||||||
}
|
}
|
||||||
|
|
||||||
SearchResponse rescored = client().prepareSearch()
|
SearchResponse rescored = prepareSearch().setPreference("test") // ensure we hit the same shards for tie-breaking
|
||||||
.setPreference("test") // ensure we hit the same shards for tie-breaking
|
|
||||||
.setFrom(0)
|
.setFrom(0)
|
||||||
.setSize(10)
|
.setSize(10)
|
||||||
.setQuery(query)
|
.setQuery(query)
|
||||||
|
@ -697,7 +686,7 @@ public class QueryRescorerIT extends ESIntegTestCase {
|
||||||
).setScoreMode(QueryRescoreMode.Total);
|
).setScoreMode(QueryRescoreMode.Total);
|
||||||
|
|
||||||
// First set the rescore window large enough that both rescores take effect
|
// First set the rescore window large enough that both rescores take effect
|
||||||
SearchRequestBuilder request = client().prepareSearch();
|
SearchRequestBuilder request = prepareSearch();
|
||||||
request.addRescorer(eightIsGreat, numDocs).addRescorer(sevenIsBetter, numDocs);
|
request.addRescorer(eightIsGreat, numDocs).addRescorer(sevenIsBetter, numDocs);
|
||||||
SearchResponse response = request.get();
|
SearchResponse response = request.get();
|
||||||
assertFirstHit(response, hasId("7"));
|
assertFirstHit(response, hasId("7"));
|
||||||
|
@ -771,7 +760,7 @@ public class QueryRescorerIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
SearchRequestBuilder request = client().prepareSearch();
|
SearchRequestBuilder request = prepareSearch();
|
||||||
request.setQuery(QueryBuilders.termQuery("text", "hello"));
|
request.setQuery(QueryBuilders.termQuery("text", "hello"));
|
||||||
request.setFrom(1);
|
request.setFrom(1);
|
||||||
request.setSize(4);
|
request.setSize(4);
|
||||||
|
@ -789,8 +778,7 @@ public class QueryRescorerIT extends ESIntegTestCase {
|
||||||
|
|
||||||
Exception exc = expectThrows(
|
Exception exc = expectThrows(
|
||||||
Exception.class,
|
Exception.class,
|
||||||
() -> client().prepareSearch()
|
() -> prepareSearch().addSort(SortBuilders.fieldSort("number"))
|
||||||
.addSort(SortBuilders.fieldSort("number"))
|
|
||||||
.setTrackScores(true)
|
.setTrackScores(true)
|
||||||
.addRescorer(new QueryRescorerBuilder(matchAllQuery()), 50)
|
.addRescorer(new QueryRescorerBuilder(matchAllQuery()), 50)
|
||||||
.get()
|
.get()
|
||||||
|
@ -800,8 +788,7 @@ public class QueryRescorerIT extends ESIntegTestCase {
|
||||||
|
|
||||||
exc = expectThrows(
|
exc = expectThrows(
|
||||||
Exception.class,
|
Exception.class,
|
||||||
() -> client().prepareSearch()
|
() -> prepareSearch().addSort(SortBuilders.fieldSort("number"))
|
||||||
.addSort(SortBuilders.fieldSort("number"))
|
|
||||||
.addSort(SortBuilders.scoreSort())
|
.addSort(SortBuilders.scoreSort())
|
||||||
.setTrackScores(true)
|
.setTrackScores(true)
|
||||||
.addRescorer(new QueryRescorerBuilder(matchAllQuery()), 50)
|
.addRescorer(new QueryRescorerBuilder(matchAllQuery()), 50)
|
||||||
|
@ -810,8 +797,7 @@ public class QueryRescorerIT extends ESIntegTestCase {
|
||||||
assertNotNull(exc.getCause());
|
assertNotNull(exc.getCause());
|
||||||
assertThat(exc.getCause().getMessage(), containsString("Cannot use [sort] option in conjunction with [rescore]."));
|
assertThat(exc.getCause().getMessage(), containsString("Cannot use [sort] option in conjunction with [rescore]."));
|
||||||
|
|
||||||
SearchResponse resp = client().prepareSearch()
|
SearchResponse resp = prepareSearch().addSort(SortBuilders.scoreSort())
|
||||||
.addSort(SortBuilders.scoreSort())
|
|
||||||
.setTrackScores(true)
|
.setTrackScores(true)
|
||||||
.addRescorer(new QueryRescorerBuilder(matchAllQuery()).setRescoreQueryWeight(100.0f), 50)
|
.addRescorer(new QueryRescorerBuilder(matchAllQuery()).setRescoreQueryWeight(100.0f), 50)
|
||||||
.get();
|
.get();
|
||||||
|
|
|
@ -99,8 +99,7 @@ public class RandomScoreFunctionIT extends ESIntegTestCase {
|
||||||
int innerIters = scaledRandomIntBetween(2, 5);
|
int innerIters = scaledRandomIntBetween(2, 5);
|
||||||
SearchHit[] hits = null;
|
SearchHit[] hits = null;
|
||||||
for (int i = 0; i < innerIters; i++) {
|
for (int i = 0; i < innerIters; i++) {
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setSize(docCount) // get all docs otherwise we are prone to tie-breaking
|
||||||
.setSize(docCount) // get all docs otherwise we are prone to tie-breaking
|
|
||||||
.setPreference(preference)
|
.setPreference(preference)
|
||||||
.setQuery(functionScoreQuery(matchAllQuery(), randomFunction().seed(seed).setField("foo")))
|
.setQuery(functionScoreQuery(matchAllQuery(), randomFunction().seed(seed).setField("foo")))
|
||||||
.get();
|
.get();
|
||||||
|
@ -281,8 +280,7 @@ public class RandomScoreFunctionIT extends ESIntegTestCase {
|
||||||
refresh();
|
refresh();
|
||||||
int iters = scaledRandomIntBetween(10, 20);
|
int iters = scaledRandomIntBetween(10, 20);
|
||||||
for (int i = 0; i < iters; ++i) {
|
for (int i = 0; i < iters; ++i) {
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(functionScoreQuery(matchAllQuery(), randomFunction()))
|
||||||
.setQuery(functionScoreQuery(matchAllQuery(), randomFunction()))
|
|
||||||
.setSize(docCount)
|
.setSize(docCount)
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
|
@ -303,20 +301,17 @@ public class RandomScoreFunctionIT extends ESIntegTestCase {
|
||||||
flushAndRefresh();
|
flushAndRefresh();
|
||||||
|
|
||||||
assertNoFailures(
|
assertNoFailures(
|
||||||
client().prepareSearch()
|
prepareSearch().setSize(docCount) // get all docs otherwise we are prone to tie-breaking
|
||||||
.setSize(docCount) // get all docs otherwise we are prone to tie-breaking
|
|
||||||
.setQuery(functionScoreQuery(matchAllQuery(), randomFunction().seed(randomInt()).setField(SeqNoFieldMapper.NAME)))
|
.setQuery(functionScoreQuery(matchAllQuery(), randomFunction().seed(randomInt()).setField(SeqNoFieldMapper.NAME)))
|
||||||
);
|
);
|
||||||
|
|
||||||
assertNoFailures(
|
assertNoFailures(
|
||||||
client().prepareSearch()
|
prepareSearch().setSize(docCount) // get all docs otherwise we are prone to tie-breaking
|
||||||
.setSize(docCount) // get all docs otherwise we are prone to tie-breaking
|
|
||||||
.setQuery(functionScoreQuery(matchAllQuery(), randomFunction().seed(randomLong()).setField(SeqNoFieldMapper.NAME)))
|
.setQuery(functionScoreQuery(matchAllQuery(), randomFunction().seed(randomLong()).setField(SeqNoFieldMapper.NAME)))
|
||||||
);
|
);
|
||||||
|
|
||||||
assertNoFailures(
|
assertNoFailures(
|
||||||
client().prepareSearch()
|
prepareSearch().setSize(docCount) // get all docs otherwise we are prone to tie-breaking
|
||||||
.setSize(docCount) // get all docs otherwise we are prone to tie-breaking
|
|
||||||
.setQuery(
|
.setQuery(
|
||||||
functionScoreQuery(
|
functionScoreQuery(
|
||||||
matchAllQuery(),
|
matchAllQuery(),
|
||||||
|
@ -343,8 +338,7 @@ public class RandomScoreFunctionIT extends ESIntegTestCase {
|
||||||
|
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(functionScoreQuery(matchAllQuery(), new RandomScoreFunctionBuilder()))
|
||||||
.setQuery(functionScoreQuery(matchAllQuery(), new RandomScoreFunctionBuilder()))
|
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
matrix[Integer.valueOf(searchResponse.getHits().getAt(0).getId())]++;
|
matrix[Integer.valueOf(searchResponse.getHits().getAt(0).getId())]++;
|
||||||
|
|
|
@ -126,24 +126,21 @@ public class GeoDistanceIT extends ESIntegTestCase {
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
// Test doc['location'].arcDistance(lat, lon)
|
// Test doc['location'].arcDistance(lat, lon)
|
||||||
SearchResponse searchResponse1 = client().prepareSearch()
|
SearchResponse searchResponse1 = prepareSearch().addStoredField("_source")
|
||||||
.addStoredField("_source")
|
|
||||||
.addScriptField("distance", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "arcDistance", Collections.emptyMap()))
|
.addScriptField("distance", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "arcDistance", Collections.emptyMap()))
|
||||||
.get();
|
.get();
|
||||||
Double resultDistance1 = searchResponse1.getHits().getHits()[0].getFields().get("distance").getValue();
|
Double resultDistance1 = searchResponse1.getHits().getHits()[0].getFields().get("distance").getValue();
|
||||||
assertThat(resultDistance1, closeTo(GeoUtils.arcDistance(src_lat, src_lon, tgt_lat, tgt_lon), 0.01d));
|
assertThat(resultDistance1, closeTo(GeoUtils.arcDistance(src_lat, src_lon, tgt_lat, tgt_lon), 0.01d));
|
||||||
|
|
||||||
// Test doc['location'].planeDistance(lat, lon)
|
// Test doc['location'].planeDistance(lat, lon)
|
||||||
SearchResponse searchResponse2 = client().prepareSearch()
|
SearchResponse searchResponse2 = prepareSearch().addStoredField("_source")
|
||||||
.addStoredField("_source")
|
|
||||||
.addScriptField("distance", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "planeDistance", Collections.emptyMap()))
|
.addScriptField("distance", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "planeDistance", Collections.emptyMap()))
|
||||||
.get();
|
.get();
|
||||||
Double resultDistance2 = searchResponse2.getHits().getHits()[0].getFields().get("distance").getValue();
|
Double resultDistance2 = searchResponse2.getHits().getHits()[0].getFields().get("distance").getValue();
|
||||||
assertThat(resultDistance2, closeTo(GeoUtils.planeDistance(src_lat, src_lon, tgt_lat, tgt_lon), 0.01d));
|
assertThat(resultDistance2, closeTo(GeoUtils.planeDistance(src_lat, src_lon, tgt_lat, tgt_lon), 0.01d));
|
||||||
|
|
||||||
// Test doc['location'].geohashDistance(lat, lon)
|
// Test doc['location'].geohashDistance(lat, lon)
|
||||||
SearchResponse searchResponse4 = client().prepareSearch()
|
SearchResponse searchResponse4 = prepareSearch().addStoredField("_source")
|
||||||
.addStoredField("_source")
|
|
||||||
.addScriptField("distance", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "geohashDistance", Collections.emptyMap()))
|
.addScriptField("distance", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "geohashDistance", Collections.emptyMap()))
|
||||||
.get();
|
.get();
|
||||||
Double resultDistance4 = searchResponse4.getHits().getHits()[0].getFields().get("distance").getValue();
|
Double resultDistance4 = searchResponse4.getHits().getHits()[0].getFields().get("distance").getValue();
|
||||||
|
@ -156,8 +153,7 @@ public class GeoDistanceIT extends ESIntegTestCase {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Test doc['location'].arcDistance(lat, lon + 360)/1000d
|
// Test doc['location'].arcDistance(lat, lon + 360)/1000d
|
||||||
SearchResponse searchResponse5 = client().prepareSearch()
|
SearchResponse searchResponse5 = prepareSearch().addStoredField("_source")
|
||||||
.addStoredField("_source")
|
|
||||||
.addScriptField(
|
.addScriptField(
|
||||||
"distance",
|
"distance",
|
||||||
new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "arcDistance(lat, lon + 360)/1000d", Collections.emptyMap())
|
new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "arcDistance(lat, lon + 360)/1000d", Collections.emptyMap())
|
||||||
|
@ -167,8 +163,7 @@ public class GeoDistanceIT extends ESIntegTestCase {
|
||||||
assertThat(resultArcDistance5, closeTo(GeoUtils.arcDistance(src_lat, src_lon, tgt_lat, tgt_lon) / 1000d, 0.01d));
|
assertThat(resultArcDistance5, closeTo(GeoUtils.arcDistance(src_lat, src_lon, tgt_lat, tgt_lon) / 1000d, 0.01d));
|
||||||
|
|
||||||
// Test doc['location'].arcDistance(lat + 360, lon)/1000d
|
// Test doc['location'].arcDistance(lat + 360, lon)/1000d
|
||||||
SearchResponse searchResponse6 = client().prepareSearch()
|
SearchResponse searchResponse6 = prepareSearch().addStoredField("_source")
|
||||||
.addStoredField("_source")
|
|
||||||
.addScriptField(
|
.addScriptField(
|
||||||
"distance",
|
"distance",
|
||||||
new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "arcDistance(lat + 360, lon)/1000d", Collections.emptyMap())
|
new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "arcDistance(lat + 360, lon)/1000d", Collections.emptyMap())
|
||||||
|
|
|
@ -788,8 +788,7 @@ public class SimpleNestedIT extends ESIntegTestCase {
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
// access id = 1, read, max value, asc, should use matt and shay
|
// access id = 1, read, max value, asc, should use matt and shay
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addSort(
|
.addSort(
|
||||||
SortBuilders.fieldSort("acl.operation.user.username")
|
SortBuilders.fieldSort("acl.operation.user.username")
|
||||||
.setNestedSort(
|
.setNestedSort(
|
||||||
|
@ -812,8 +811,7 @@ public class SimpleNestedIT extends ESIntegTestCase {
|
||||||
assertThat(searchResponse.getHits().getHits()[1].getSortValues()[0].toString(), equalTo("shay"));
|
assertThat(searchResponse.getHits().getHits()[1].getSortValues()[0].toString(), equalTo("shay"));
|
||||||
|
|
||||||
// access id = 1, read, min value, asc, should now use adrien and luca
|
// access id = 1, read, min value, asc, should now use adrien and luca
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addSort(
|
.addSort(
|
||||||
SortBuilders.fieldSort("acl.operation.user.username")
|
SortBuilders.fieldSort("acl.operation.user.username")
|
||||||
.setNestedSort(
|
.setNestedSort(
|
||||||
|
@ -836,8 +834,7 @@ public class SimpleNestedIT extends ESIntegTestCase {
|
||||||
assertThat(searchResponse.getHits().getHits()[1].getSortValues()[0].toString(), equalTo("luca"));
|
assertThat(searchResponse.getHits().getHits()[1].getSortValues()[0].toString(), equalTo("luca"));
|
||||||
|
|
||||||
// execute, by matt or luca, by user id, sort missing first
|
// execute, by matt or luca, by user id, sort missing first
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addSort(
|
.addSort(
|
||||||
SortBuilders.fieldSort("acl.operation.user.id")
|
SortBuilders.fieldSort("acl.operation.user.id")
|
||||||
.setNestedSort(
|
.setNestedSort(
|
||||||
|
@ -863,8 +860,7 @@ public class SimpleNestedIT extends ESIntegTestCase {
|
||||||
assertThat(searchResponse.getHits().getHits()[1].getSortValues()[0].toString(), equalTo("1"));
|
assertThat(searchResponse.getHits().getHits()[1].getSortValues()[0].toString(), equalTo("1"));
|
||||||
|
|
||||||
// execute, by matt or luca, by username, sort missing last (default)
|
// execute, by matt or luca, by username, sort missing last (default)
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addSort(
|
.addSort(
|
||||||
SortBuilders.fieldSort("acl.operation.user.username")
|
SortBuilders.fieldSort("acl.operation.user.username")
|
||||||
.setNestedSort(
|
.setNestedSort(
|
||||||
|
@ -948,8 +944,7 @@ public class SimpleNestedIT extends ESIntegTestCase {
|
||||||
|
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(termQuery("_id", 2))
|
||||||
.setQuery(termQuery("_id", 2))
|
|
||||||
.addSort(
|
.addSort(
|
||||||
SortBuilders.fieldSort("nested1.nested2.sortVal")
|
SortBuilders.fieldSort("nested1.nested2.sortVal")
|
||||||
.setNestedSort(
|
.setNestedSort(
|
||||||
|
@ -1131,8 +1126,7 @@ public class SimpleNestedIT extends ESIntegTestCase {
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
// Without nested filter
|
// Without nested filter
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addSort(
|
.addSort(
|
||||||
SortBuilders.fieldSort("parent.child.child_values")
|
SortBuilders.fieldSort("parent.child.child_values")
|
||||||
.setNestedSort(new NestedSortBuilder("parent.child"))
|
.setNestedSort(new NestedSortBuilder("parent.child"))
|
||||||
|
@ -1151,8 +1145,7 @@ public class SimpleNestedIT extends ESIntegTestCase {
|
||||||
// With nested filter
|
// With nested filter
|
||||||
NestedSortBuilder nestedSort = new NestedSortBuilder("parent.child");
|
NestedSortBuilder nestedSort = new NestedSortBuilder("parent.child");
|
||||||
nestedSort.setFilter(QueryBuilders.termQuery("parent.child.filter", true));
|
nestedSort.setFilter(QueryBuilders.termQuery("parent.child.filter", true));
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addSort(SortBuilders.fieldSort("parent.child.child_values").setNestedSort(nestedSort).order(SortOrder.ASC))
|
.addSort(SortBuilders.fieldSort("parent.child.child_values").setNestedSort(nestedSort).order(SortOrder.ASC))
|
||||||
.get();
|
.get();
|
||||||
assertHitCount(searchResponse, 3);
|
assertHitCount(searchResponse, 3);
|
||||||
|
@ -1165,8 +1158,7 @@ public class SimpleNestedIT extends ESIntegTestCase {
|
||||||
assertThat(searchResponse.getHits().getHits()[2].getSortValues()[0].toString(), equalTo("3"));
|
assertThat(searchResponse.getHits().getHits()[2].getSortValues()[0].toString(), equalTo("3"));
|
||||||
|
|
||||||
// Nested path should be automatically detected, expect same results as above search request
|
// Nested path should be automatically detected, expect same results as above search request
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addSort(SortBuilders.fieldSort("parent.child.child_values").setNestedSort(nestedSort).order(SortOrder.ASC))
|
.addSort(SortBuilders.fieldSort("parent.child.child_values").setNestedSort(nestedSort).order(SortOrder.ASC))
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
|
@ -1180,8 +1172,7 @@ public class SimpleNestedIT extends ESIntegTestCase {
|
||||||
assertThat(searchResponse.getHits().getHits()[2].getSortValues()[0].toString(), equalTo("3"));
|
assertThat(searchResponse.getHits().getHits()[2].getSortValues()[0].toString(), equalTo("3"));
|
||||||
|
|
||||||
nestedSort.setFilter(QueryBuilders.termQuery("parent.filter", false));
|
nestedSort.setFilter(QueryBuilders.termQuery("parent.filter", false));
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addSort(SortBuilders.fieldSort("parent.parent_values").setNestedSort(nestedSort).order(SortOrder.ASC))
|
.addSort(SortBuilders.fieldSort("parent.parent_values").setNestedSort(nestedSort).order(SortOrder.ASC))
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
|
@ -1194,8 +1185,7 @@ public class SimpleNestedIT extends ESIntegTestCase {
|
||||||
assertThat(searchResponse.getHits().getHits()[2].getId(), equalTo("3"));
|
assertThat(searchResponse.getHits().getHits()[2].getId(), equalTo("3"));
|
||||||
assertThat(searchResponse.getHits().getHits()[2].getSortValues()[0].toString(), equalTo("3"));
|
assertThat(searchResponse.getHits().getHits()[2].getSortValues()[0].toString(), equalTo("3"));
|
||||||
|
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addSort(
|
.addSort(
|
||||||
SortBuilders.fieldSort("parent.child.child_values")
|
SortBuilders.fieldSort("parent.child.child_values")
|
||||||
.setNestedSort(
|
.setNestedSort(
|
||||||
|
@ -1217,8 +1207,7 @@ public class SimpleNestedIT extends ESIntegTestCase {
|
||||||
assertThat(searchResponse.getHits().getHits()[2].getSortValues()[0].toString(), equalTo("6"));
|
assertThat(searchResponse.getHits().getHits()[2].getSortValues()[0].toString(), equalTo("6"));
|
||||||
|
|
||||||
// Check if closest nested type is resolved
|
// Check if closest nested type is resolved
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addSort(
|
.addSort(
|
||||||
SortBuilders.fieldSort("parent.child.child_obj.value")
|
SortBuilders.fieldSort("parent.child.child_obj.value")
|
||||||
.setNestedSort(new NestedSortBuilder("parent.child").setFilter(QueryBuilders.termQuery("parent.child.filter", true)))
|
.setNestedSort(new NestedSortBuilder("parent.child").setFilter(QueryBuilders.termQuery("parent.child.filter", true)))
|
||||||
|
@ -1236,8 +1225,7 @@ public class SimpleNestedIT extends ESIntegTestCase {
|
||||||
assertThat(searchResponse.getHits().getHits()[2].getSortValues()[0].toString(), equalTo("3"));
|
assertThat(searchResponse.getHits().getHits()[2].getSortValues()[0].toString(), equalTo("3"));
|
||||||
|
|
||||||
// Sort mode: sum
|
// Sort mode: sum
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addSort(
|
.addSort(
|
||||||
SortBuilders.fieldSort("parent.child.child_values")
|
SortBuilders.fieldSort("parent.child.child_values")
|
||||||
.setNestedSort(new NestedSortBuilder("parent.child"))
|
.setNestedSort(new NestedSortBuilder("parent.child"))
|
||||||
|
@ -1255,8 +1243,7 @@ public class SimpleNestedIT extends ESIntegTestCase {
|
||||||
assertThat(searchResponse.getHits().getHits()[2].getId(), equalTo("1"));
|
assertThat(searchResponse.getHits().getHits()[2].getId(), equalTo("1"));
|
||||||
assertThat(searchResponse.getHits().getHits()[2].getSortValues()[0].toString(), equalTo("11"));
|
assertThat(searchResponse.getHits().getHits()[2].getSortValues()[0].toString(), equalTo("11"));
|
||||||
|
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addSort(
|
.addSort(
|
||||||
SortBuilders.fieldSort("parent.child.child_values")
|
SortBuilders.fieldSort("parent.child.child_values")
|
||||||
.setNestedSort(new NestedSortBuilder("parent.child"))
|
.setNestedSort(new NestedSortBuilder("parent.child"))
|
||||||
|
@ -1275,8 +1262,7 @@ public class SimpleNestedIT extends ESIntegTestCase {
|
||||||
assertThat(searchResponse.getHits().getHits()[2].getSortValues()[0].toString(), equalTo("2"));
|
assertThat(searchResponse.getHits().getHits()[2].getSortValues()[0].toString(), equalTo("2"));
|
||||||
|
|
||||||
// Sort mode: sum with filter
|
// Sort mode: sum with filter
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addSort(
|
.addSort(
|
||||||
SortBuilders.fieldSort("parent.child.child_values")
|
SortBuilders.fieldSort("parent.child.child_values")
|
||||||
.setNestedSort(new NestedSortBuilder("parent.child").setFilter(QueryBuilders.termQuery("parent.child.filter", true)))
|
.setNestedSort(new NestedSortBuilder("parent.child").setFilter(QueryBuilders.termQuery("parent.child.filter", true)))
|
||||||
|
@ -1295,8 +1281,7 @@ public class SimpleNestedIT extends ESIntegTestCase {
|
||||||
assertThat(searchResponse.getHits().getHits()[2].getSortValues()[0].toString(), equalTo("3"));
|
assertThat(searchResponse.getHits().getHits()[2].getSortValues()[0].toString(), equalTo("3"));
|
||||||
|
|
||||||
// Sort mode: avg
|
// Sort mode: avg
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addSort(
|
.addSort(
|
||||||
SortBuilders.fieldSort("parent.child.child_values")
|
SortBuilders.fieldSort("parent.child.child_values")
|
||||||
.setNestedSort(new NestedSortBuilder("parent.child"))
|
.setNestedSort(new NestedSortBuilder("parent.child"))
|
||||||
|
@ -1314,8 +1299,7 @@ public class SimpleNestedIT extends ESIntegTestCase {
|
||||||
assertThat(searchResponse.getHits().getHits()[2].getId(), equalTo("1"));
|
assertThat(searchResponse.getHits().getHits()[2].getId(), equalTo("1"));
|
||||||
assertThat(searchResponse.getHits().getHits()[2].getSortValues()[0].toString(), equalTo("3"));
|
assertThat(searchResponse.getHits().getHits()[2].getSortValues()[0].toString(), equalTo("3"));
|
||||||
|
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addSort(
|
.addSort(
|
||||||
SortBuilders.fieldSort("parent.child.child_values")
|
SortBuilders.fieldSort("parent.child.child_values")
|
||||||
.setNestedSort(new NestedSortBuilder("parent.child"))
|
.setNestedSort(new NestedSortBuilder("parent.child"))
|
||||||
|
@ -1334,8 +1318,7 @@ public class SimpleNestedIT extends ESIntegTestCase {
|
||||||
assertThat(searchResponse.getHits().getHits()[2].getSortValues()[0].toString(), equalTo("1"));
|
assertThat(searchResponse.getHits().getHits()[2].getSortValues()[0].toString(), equalTo("1"));
|
||||||
|
|
||||||
// Sort mode: avg with filter
|
// Sort mode: avg with filter
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addSort(
|
.addSort(
|
||||||
SortBuilders.fieldSort("parent.child.child_values")
|
SortBuilders.fieldSort("parent.child.child_values")
|
||||||
.setNestedSort(new NestedSortBuilder("parent.child").setFilter(QueryBuilders.termQuery("parent.child.filter", true)))
|
.setNestedSort(new NestedSortBuilder("parent.child").setFilter(QueryBuilders.termQuery("parent.child.filter", true)))
|
||||||
|
|
|
@ -67,8 +67,7 @@ public class DfsProfilerIT extends ESIntegTestCase {
|
||||||
for (int i = 0; i < iters; i++) {
|
for (int i = 0; i < iters; i++) {
|
||||||
QueryBuilder q = randomQueryBuilder(List.of(textField), List.of(numericField), numDocs, 3);
|
QueryBuilder q = randomQueryBuilder(List.of(textField), List.of(numericField), numDocs, 3);
|
||||||
logger.info("Query: {}", q);
|
logger.info("Query: {}", q);
|
||||||
SearchResponse resp = client().prepareSearch()
|
SearchResponse resp = prepareSearch().setQuery(q)
|
||||||
.setQuery(q)
|
|
||||||
.setTrackTotalHits(true)
|
.setTrackTotalHits(true)
|
||||||
.setProfile(true)
|
.setProfile(true)
|
||||||
.setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
|
.setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
|
||||||
|
|
|
@ -63,8 +63,7 @@ public class QueryProfilerIT extends ESIntegTestCase {
|
||||||
QueryBuilder q = randomQueryBuilder(stringFields, numericFields, numDocs, 3);
|
QueryBuilder q = randomQueryBuilder(stringFields, numericFields, numDocs, 3);
|
||||||
logger.info("Query: {}", q);
|
logger.info("Query: {}", q);
|
||||||
|
|
||||||
SearchResponse resp = client().prepareSearch()
|
SearchResponse resp = prepareSearch().setQuery(q)
|
||||||
.setQuery(q)
|
|
||||||
.setTrackTotalHits(true)
|
.setTrackTotalHits(true)
|
||||||
.setProfile(true)
|
.setProfile(true)
|
||||||
.setSearchType(SearchType.QUERY_THEN_FETCH)
|
.setSearchType(SearchType.QUERY_THEN_FETCH)
|
||||||
|
@ -186,7 +185,7 @@ public class QueryProfilerIT extends ESIntegTestCase {
|
||||||
|
|
||||||
QueryBuilder q = QueryBuilders.matchQuery("field1", "one");
|
QueryBuilder q = QueryBuilders.matchQuery("field1", "one");
|
||||||
|
|
||||||
SearchResponse resp = client().prepareSearch().setQuery(q).setProfile(true).setSearchType(SearchType.QUERY_THEN_FETCH).get();
|
SearchResponse resp = prepareSearch().setQuery(q).setProfile(true).setSearchType(SearchType.QUERY_THEN_FETCH).get();
|
||||||
|
|
||||||
Map<String, SearchProfileShardResult> p = resp.getProfileResults();
|
Map<String, SearchProfileShardResult> p = resp.getProfileResults();
|
||||||
assertNotNull(p);
|
assertNotNull(p);
|
||||||
|
@ -227,7 +226,7 @@ public class QueryProfilerIT extends ESIntegTestCase {
|
||||||
.must(QueryBuilders.matchQuery("field1", "one"))
|
.must(QueryBuilders.matchQuery("field1", "one"))
|
||||||
.must(QueryBuilders.matchQuery("field1", "two"));
|
.must(QueryBuilders.matchQuery("field1", "two"));
|
||||||
|
|
||||||
SearchResponse resp = client().prepareSearch().setQuery(q).setProfile(true).setSearchType(SearchType.QUERY_THEN_FETCH).get();
|
SearchResponse resp = prepareSearch().setQuery(q).setProfile(true).setSearchType(SearchType.QUERY_THEN_FETCH).get();
|
||||||
|
|
||||||
Map<String, SearchProfileShardResult> p = resp.getProfileResults();
|
Map<String, SearchProfileShardResult> p = resp.getProfileResults();
|
||||||
assertNotNull(p);
|
assertNotNull(p);
|
||||||
|
@ -288,7 +287,7 @@ public class QueryProfilerIT extends ESIntegTestCase {
|
||||||
QueryBuilder q = QueryBuilders.boolQuery();
|
QueryBuilder q = QueryBuilders.boolQuery();
|
||||||
logger.info("Query: {}", q);
|
logger.info("Query: {}", q);
|
||||||
|
|
||||||
SearchResponse resp = client().prepareSearch().setQuery(q).setProfile(true).setSearchType(SearchType.QUERY_THEN_FETCH).get();
|
SearchResponse resp = prepareSearch().setQuery(q).setProfile(true).setSearchType(SearchType.QUERY_THEN_FETCH).get();
|
||||||
|
|
||||||
assertNotNull("Profile response element should not be null", resp.getProfileResults());
|
assertNotNull("Profile response element should not be null", resp.getProfileResults());
|
||||||
assertThat("Profile response should not be an empty array", resp.getProfileResults().size(), not(0));
|
assertThat("Profile response should not be an empty array", resp.getProfileResults().size(), not(0));
|
||||||
|
@ -333,7 +332,7 @@ public class QueryProfilerIT extends ESIntegTestCase {
|
||||||
|
|
||||||
logger.info("Query: {}", q);
|
logger.info("Query: {}", q);
|
||||||
|
|
||||||
SearchResponse resp = client().prepareSearch().setQuery(q).setProfile(true).setSearchType(SearchType.QUERY_THEN_FETCH).get();
|
SearchResponse resp = prepareSearch().setQuery(q).setProfile(true).setSearchType(SearchType.QUERY_THEN_FETCH).get();
|
||||||
|
|
||||||
assertNotNull("Profile response element should not be null", resp.getProfileResults());
|
assertNotNull("Profile response element should not be null", resp.getProfileResults());
|
||||||
assertThat("Profile response should not be an empty array", resp.getProfileResults().size(), not(0));
|
assertThat("Profile response should not be an empty array", resp.getProfileResults().size(), not(0));
|
||||||
|
@ -373,7 +372,7 @@ public class QueryProfilerIT extends ESIntegTestCase {
|
||||||
.negativeBoost(randomFloat());
|
.negativeBoost(randomFloat());
|
||||||
logger.info("Query: {}", q);
|
logger.info("Query: {}", q);
|
||||||
|
|
||||||
SearchResponse resp = client().prepareSearch().setQuery(q).setProfile(true).setSearchType(SearchType.QUERY_THEN_FETCH).get();
|
SearchResponse resp = prepareSearch().setQuery(q).setProfile(true).setSearchType(SearchType.QUERY_THEN_FETCH).get();
|
||||||
|
|
||||||
assertNotNull("Profile response element should not be null", resp.getProfileResults());
|
assertNotNull("Profile response element should not be null", resp.getProfileResults());
|
||||||
assertThat("Profile response should not be an empty array", resp.getProfileResults().size(), not(0));
|
assertThat("Profile response should not be an empty array", resp.getProfileResults().size(), not(0));
|
||||||
|
@ -413,7 +412,7 @@ public class QueryProfilerIT extends ESIntegTestCase {
|
||||||
.add(QueryBuilders.rangeQuery("field2").from(null).to(73).includeLower(true).includeUpper(true));
|
.add(QueryBuilders.rangeQuery("field2").from(null).to(73).includeLower(true).includeUpper(true));
|
||||||
logger.info("Query: {}", q);
|
logger.info("Query: {}", q);
|
||||||
|
|
||||||
SearchResponse resp = client().prepareSearch().setQuery(q).setProfile(true).setSearchType(SearchType.QUERY_THEN_FETCH).get();
|
SearchResponse resp = prepareSearch().setQuery(q).setProfile(true).setSearchType(SearchType.QUERY_THEN_FETCH).get();
|
||||||
|
|
||||||
assertNotNull("Profile response element should not be null", resp.getProfileResults());
|
assertNotNull("Profile response element should not be null", resp.getProfileResults());
|
||||||
assertThat("Profile response should not be an empty array", resp.getProfileResults().size(), not(0));
|
assertThat("Profile response should not be an empty array", resp.getProfileResults().size(), not(0));
|
||||||
|
@ -452,7 +451,7 @@ public class QueryProfilerIT extends ESIntegTestCase {
|
||||||
|
|
||||||
logger.info("Query: {}", q.toString());
|
logger.info("Query: {}", q.toString());
|
||||||
|
|
||||||
SearchResponse resp = client().prepareSearch().setQuery(q).setProfile(true).setSearchType(SearchType.QUERY_THEN_FETCH).get();
|
SearchResponse resp = prepareSearch().setQuery(q).setProfile(true).setSearchType(SearchType.QUERY_THEN_FETCH).get();
|
||||||
|
|
||||||
assertNotNull("Profile response element should not be null", resp.getProfileResults());
|
assertNotNull("Profile response element should not be null", resp.getProfileResults());
|
||||||
assertThat("Profile response should not be an empty array", resp.getProfileResults().size(), not(0));
|
assertThat("Profile response should not be an empty array", resp.getProfileResults().size(), not(0));
|
||||||
|
@ -493,8 +492,7 @@ public class QueryProfilerIT extends ESIntegTestCase {
|
||||||
|
|
||||||
logger.info("Query: {}", q);
|
logger.info("Query: {}", q);
|
||||||
|
|
||||||
SearchResponse resp = client().prepareSearch()
|
SearchResponse resp = prepareSearch().setQuery(q)
|
||||||
.setQuery(q)
|
|
||||||
.setIndices("test")
|
.setIndices("test")
|
||||||
.setProfile(true)
|
.setProfile(true)
|
||||||
.setSearchType(SearchType.QUERY_THEN_FETCH)
|
.setSearchType(SearchType.QUERY_THEN_FETCH)
|
||||||
|
@ -545,7 +543,7 @@ public class QueryProfilerIT extends ESIntegTestCase {
|
||||||
|
|
||||||
logger.info("Query: {}", q);
|
logger.info("Query: {}", q);
|
||||||
|
|
||||||
SearchResponse resp = client().prepareSearch().setQuery(q).setProfile(false).get();
|
SearchResponse resp = prepareSearch().setQuery(q).setProfile(false).get();
|
||||||
assertThat("Profile response element should be an empty map", resp.getProfileResults().size(), equalTo(0));
|
assertThat("Profile response element should be an empty map", resp.getProfileResults().size(), equalTo(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,10 +67,10 @@ public class SearchPreferenceIT extends ESIntegTestCase {
|
||||||
"_prefer_nodes:somenode,server2" };
|
"_prefer_nodes:somenode,server2" };
|
||||||
for (String pref : preferences) {
|
for (String pref : preferences) {
|
||||||
logger.info("--> Testing out preference={}", pref);
|
logger.info("--> Testing out preference={}", pref);
|
||||||
SearchResponse searchResponse = client().prepareSearch().setSize(0).setPreference(pref).get();
|
SearchResponse searchResponse = prepareSearch().setSize(0).setPreference(pref).get();
|
||||||
assertThat(RestStatus.OK, equalTo(searchResponse.status()));
|
assertThat(RestStatus.OK, equalTo(searchResponse.status()));
|
||||||
assertThat(pref, searchResponse.getFailedShards(), greaterThanOrEqualTo(0));
|
assertThat(pref, searchResponse.getFailedShards(), greaterThanOrEqualTo(0));
|
||||||
searchResponse = client().prepareSearch().setPreference(pref).get();
|
searchResponse = prepareSearch().setPreference(pref).get();
|
||||||
assertThat(RestStatus.OK, equalTo(searchResponse.status()));
|
assertThat(RestStatus.OK, equalTo(searchResponse.status()));
|
||||||
assertThat(pref, searchResponse.getFailedShards(), greaterThanOrEqualTo(0));
|
assertThat(pref, searchResponse.getFailedShards(), greaterThanOrEqualTo(0));
|
||||||
}
|
}
|
||||||
|
@ -112,13 +112,13 @@ public class SearchPreferenceIT extends ESIntegTestCase {
|
||||||
client().prepareIndex("test").setSource("field1", "value1").get();
|
client().prepareIndex("test").setSource("field1", "value1").get();
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch().setQuery(matchAllQuery()).get();
|
SearchResponse searchResponse = prepareSearch().setQuery(matchAllQuery()).get();
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
||||||
|
|
||||||
searchResponse = client().prepareSearch().setQuery(matchAllQuery()).setPreference("_local").get();
|
searchResponse = prepareSearch().setQuery(matchAllQuery()).setPreference("_local").get();
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
||||||
|
|
||||||
searchResponse = client().prepareSearch().setQuery(matchAllQuery()).setPreference("1234").get();
|
searchResponse = prepareSearch().setQuery(matchAllQuery()).setPreference("1234").get();
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ public class SearchPreferenceIT extends ESIntegTestCase {
|
||||||
ensureGreen();
|
ensureGreen();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
client().prepareSearch().setQuery(matchAllQuery()).setPreference("_only_nodes:DOES-NOT-EXIST").get();
|
prepareSearch().setQuery(matchAllQuery()).setPreference("_only_nodes:DOES-NOT-EXIST").get();
|
||||||
fail("Expected IllegalArgumentException");
|
fail("Expected IllegalArgumentException");
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
assertThat(e, hasToString(containsString("no data nodes with criteria [DOES-NOT-EXIST] found for shard: [test][")));
|
assertThat(e, hasToString(containsString("no data nodes with criteria [DOES-NOT-EXIST] found for shard: [test][")));
|
||||||
|
|
|
@ -114,10 +114,9 @@ public class ScriptQuerySearchIT extends ESIntegTestCase {
|
||||||
flush();
|
flush();
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
SearchResponse response = client().prepareSearch()
|
SearchResponse response = prepareSearch().setQuery(
|
||||||
.setQuery(
|
scriptQuery(new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc['binaryData'].get(0).length > 15", emptyMap()))
|
||||||
scriptQuery(new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc['binaryData'].get(0).length > 15", emptyMap()))
|
)
|
||||||
)
|
|
||||||
.addScriptField(
|
.addScriptField(
|
||||||
"sbinaryData",
|
"sbinaryData",
|
||||||
new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc['binaryData'].get(0).length", emptyMap())
|
new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc['binaryData'].get(0).length", emptyMap())
|
||||||
|
@ -169,8 +168,9 @@ public class ScriptQuerySearchIT extends ESIntegTestCase {
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
logger.info("running doc['num1'].value > 1");
|
logger.info("running doc['num1'].value > 1");
|
||||||
SearchResponse response = client().prepareSearch()
|
SearchResponse response = prepareSearch().setQuery(
|
||||||
.setQuery(scriptQuery(new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc['num1'].value > 1", Collections.emptyMap())))
|
scriptQuery(new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc['num1'].value > 1", Collections.emptyMap()))
|
||||||
|
)
|
||||||
.addSort("num1", SortOrder.ASC)
|
.addSort("num1", SortOrder.ASC)
|
||||||
.addScriptField("sNum1", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc['num1'].value", Collections.emptyMap()))
|
.addScriptField("sNum1", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc['num1'].value", Collections.emptyMap()))
|
||||||
.get();
|
.get();
|
||||||
|
@ -185,8 +185,9 @@ public class ScriptQuerySearchIT extends ESIntegTestCase {
|
||||||
params.put("param1", 2);
|
params.put("param1", 2);
|
||||||
|
|
||||||
logger.info("running doc['num1'].value > param1");
|
logger.info("running doc['num1'].value > param1");
|
||||||
response = client().prepareSearch()
|
response = prepareSearch().setQuery(
|
||||||
.setQuery(scriptQuery(new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc['num1'].value > param1", params)))
|
scriptQuery(new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc['num1'].value > param1", params))
|
||||||
|
)
|
||||||
.addSort("num1", SortOrder.ASC)
|
.addSort("num1", SortOrder.ASC)
|
||||||
.addScriptField("sNum1", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc['num1'].value", Collections.emptyMap()))
|
.addScriptField("sNum1", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc['num1'].value", Collections.emptyMap()))
|
||||||
.get();
|
.get();
|
||||||
|
@ -198,8 +199,9 @@ public class ScriptQuerySearchIT extends ESIntegTestCase {
|
||||||
params = new HashMap<>();
|
params = new HashMap<>();
|
||||||
params.put("param1", -1);
|
params.put("param1", -1);
|
||||||
logger.info("running doc['num1'].value > param1");
|
logger.info("running doc['num1'].value > param1");
|
||||||
response = client().prepareSearch()
|
response = prepareSearch().setQuery(
|
||||||
.setQuery(scriptQuery(new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc['num1'].value > param1", params)))
|
scriptQuery(new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc['num1'].value > param1", params))
|
||||||
|
)
|
||||||
.addSort("num1", SortOrder.ASC)
|
.addSort("num1", SortOrder.ASC)
|
||||||
.addScriptField("sNum1", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc['num1'].value", Collections.emptyMap()))
|
.addScriptField("sNum1", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc['num1'].value", Collections.emptyMap()))
|
||||||
.get();
|
.get();
|
||||||
|
|
|
@ -81,8 +81,7 @@ public class SearchScrollIT extends ESIntegTestCase {
|
||||||
|
|
||||||
indicesAdmin().prepareRefresh().get();
|
indicesAdmin().prepareRefresh().get();
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.setSize(35)
|
.setSize(35)
|
||||||
.setScroll(TimeValue.timeValueMinutes(2))
|
.setScroll(TimeValue.timeValueMinutes(2))
|
||||||
.addSort("field", SortOrder.ASC)
|
.addSort("field", SortOrder.ASC)
|
||||||
|
@ -134,8 +133,7 @@ public class SearchScrollIT extends ESIntegTestCase {
|
||||||
|
|
||||||
indicesAdmin().prepareRefresh().get();
|
indicesAdmin().prepareRefresh().get();
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setSearchType(SearchType.QUERY_THEN_FETCH)
|
||||||
.setSearchType(SearchType.QUERY_THEN_FETCH)
|
|
||||||
.setQuery(matchAllQuery())
|
.setQuery(matchAllQuery())
|
||||||
.setSize(3)
|
.setSize(3)
|
||||||
.setScroll(TimeValue.timeValueMinutes(2))
|
.setScroll(TimeValue.timeValueMinutes(2))
|
||||||
|
@ -202,26 +200,13 @@ public class SearchScrollIT extends ESIntegTestCase {
|
||||||
|
|
||||||
indicesAdmin().prepareRefresh().get();
|
indicesAdmin().prepareRefresh().get();
|
||||||
|
|
||||||
assertThat(client().prepareSearch().setSize(0).setQuery(matchAllQuery()).get().getHits().getTotalHits().value, equalTo(500L));
|
assertThat(prepareSearch().setSize(0).setQuery(matchAllQuery()).get().getHits().getTotalHits().value, equalTo(500L));
|
||||||
assertThat(
|
assertThat(prepareSearch().setSize(0).setQuery(termQuery("message", "test")).get().getHits().getTotalHits().value, equalTo(500L));
|
||||||
client().prepareSearch().setSize(0).setQuery(termQuery("message", "test")).get().getHits().getTotalHits().value,
|
assertThat(prepareSearch().setSize(0).setQuery(termQuery("message", "test")).get().getHits().getTotalHits().value, equalTo(500L));
|
||||||
equalTo(500L)
|
assertThat(prepareSearch().setSize(0).setQuery(termQuery("message", "update")).get().getHits().getTotalHits().value, equalTo(0L));
|
||||||
);
|
assertThat(prepareSearch().setSize(0).setQuery(termQuery("message", "update")).get().getHits().getTotalHits().value, equalTo(0L));
|
||||||
assertThat(
|
|
||||||
client().prepareSearch().setSize(0).setQuery(termQuery("message", "test")).get().getHits().getTotalHits().value,
|
|
||||||
equalTo(500L)
|
|
||||||
);
|
|
||||||
assertThat(
|
|
||||||
client().prepareSearch().setSize(0).setQuery(termQuery("message", "update")).get().getHits().getTotalHits().value,
|
|
||||||
equalTo(0L)
|
|
||||||
);
|
|
||||||
assertThat(
|
|
||||||
client().prepareSearch().setSize(0).setQuery(termQuery("message", "update")).get().getHits().getTotalHits().value,
|
|
||||||
equalTo(0L)
|
|
||||||
);
|
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(queryStringQuery("user:kimchy"))
|
||||||
.setQuery(queryStringQuery("user:kimchy"))
|
|
||||||
.setSize(35)
|
.setSize(35)
|
||||||
.setScroll(TimeValue.timeValueMinutes(2))
|
.setScroll(TimeValue.timeValueMinutes(2))
|
||||||
.addSort("postDate", SortOrder.ASC)
|
.addSort("postDate", SortOrder.ASC)
|
||||||
|
@ -237,21 +222,15 @@ public class SearchScrollIT extends ESIntegTestCase {
|
||||||
} while (searchResponse.getHits().getHits().length > 0);
|
} while (searchResponse.getHits().getHits().length > 0);
|
||||||
|
|
||||||
indicesAdmin().prepareRefresh().get();
|
indicesAdmin().prepareRefresh().get();
|
||||||
assertThat(client().prepareSearch().setSize(0).setQuery(matchAllQuery()).get().getHits().getTotalHits().value, equalTo(500L));
|
assertThat(prepareSearch().setSize(0).setQuery(matchAllQuery()).get().getHits().getTotalHits().value, equalTo(500L));
|
||||||
|
assertThat(prepareSearch().setSize(0).setQuery(termQuery("message", "test")).get().getHits().getTotalHits().value, equalTo(0L));
|
||||||
|
assertThat(prepareSearch().setSize(0).setQuery(termQuery("message", "test")).get().getHits().getTotalHits().value, equalTo(0L));
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch().setSize(0).setQuery(termQuery("message", "test")).get().getHits().getTotalHits().value,
|
prepareSearch().setSize(0).setQuery(termQuery("message", "update")).get().getHits().getTotalHits().value,
|
||||||
equalTo(0L)
|
|
||||||
);
|
|
||||||
assertThat(
|
|
||||||
client().prepareSearch().setSize(0).setQuery(termQuery("message", "test")).get().getHits().getTotalHits().value,
|
|
||||||
equalTo(0L)
|
|
||||||
);
|
|
||||||
assertThat(
|
|
||||||
client().prepareSearch().setSize(0).setQuery(termQuery("message", "update")).get().getHits().getTotalHits().value,
|
|
||||||
equalTo(500L)
|
equalTo(500L)
|
||||||
);
|
);
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch().setSize(0).setQuery(termQuery("message", "update")).get().getHits().getTotalHits().value,
|
prepareSearch().setSize(0).setQuery(termQuery("message", "update")).get().getHits().getTotalHits().value,
|
||||||
equalTo(500L)
|
equalTo(500L)
|
||||||
);
|
);
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -274,16 +253,14 @@ public class SearchScrollIT extends ESIntegTestCase {
|
||||||
|
|
||||||
indicesAdmin().prepareRefresh().get();
|
indicesAdmin().prepareRefresh().get();
|
||||||
|
|
||||||
SearchResponse searchResponse1 = client().prepareSearch()
|
SearchResponse searchResponse1 = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.setSize(35)
|
.setSize(35)
|
||||||
.setScroll(TimeValue.timeValueMinutes(2))
|
.setScroll(TimeValue.timeValueMinutes(2))
|
||||||
.setSearchType(SearchType.QUERY_THEN_FETCH)
|
.setSearchType(SearchType.QUERY_THEN_FETCH)
|
||||||
.addSort("field", SortOrder.ASC)
|
.addSort("field", SortOrder.ASC)
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
SearchResponse searchResponse2 = client().prepareSearch()
|
SearchResponse searchResponse2 = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.setSize(35)
|
.setSize(35)
|
||||||
.setScroll(TimeValue.timeValueMinutes(2))
|
.setScroll(TimeValue.timeValueMinutes(2))
|
||||||
.setSearchType(SearchType.QUERY_THEN_FETCH)
|
.setSearchType(SearchType.QUERY_THEN_FETCH)
|
||||||
|
@ -394,16 +371,14 @@ public class SearchScrollIT extends ESIntegTestCase {
|
||||||
|
|
||||||
indicesAdmin().prepareRefresh().get();
|
indicesAdmin().prepareRefresh().get();
|
||||||
|
|
||||||
SearchResponse searchResponse1 = client().prepareSearch()
|
SearchResponse searchResponse1 = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.setSize(35)
|
.setSize(35)
|
||||||
.setScroll(TimeValue.timeValueMinutes(2))
|
.setScroll(TimeValue.timeValueMinutes(2))
|
||||||
.setSearchType(SearchType.QUERY_THEN_FETCH)
|
.setSearchType(SearchType.QUERY_THEN_FETCH)
|
||||||
.addSort("field", SortOrder.ASC)
|
.addSort("field", SortOrder.ASC)
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
SearchResponse searchResponse2 = client().prepareSearch()
|
SearchResponse searchResponse2 = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.setSize(35)
|
.setSize(35)
|
||||||
.setScroll(TimeValue.timeValueMinutes(2))
|
.setScroll(TimeValue.timeValueMinutes(2))
|
||||||
.setSearchType(SearchType.QUERY_THEN_FETCH)
|
.setSearchType(SearchType.QUERY_THEN_FETCH)
|
||||||
|
@ -538,8 +513,7 @@ public class SearchScrollIT extends ESIntegTestCase {
|
||||||
client().prepareIndex("test").setId(Integer.toString(i)).setSource("field", i).get();
|
client().prepareIndex("test").setId(Integer.toString(i)).setSource("field", i).get();
|
||||||
}
|
}
|
||||||
refresh();
|
refresh();
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.setSize(35)
|
.setSize(35)
|
||||||
.setScroll(TimeValue.timeValueMinutes(2))
|
.setScroll(TimeValue.timeValueMinutes(2))
|
||||||
.addSort("field", SortOrder.ASC)
|
.addSort("field", SortOrder.ASC)
|
||||||
|
@ -602,7 +576,7 @@ public class SearchScrollIT extends ESIntegTestCase {
|
||||||
|
|
||||||
Exception exc = expectThrows(
|
Exception exc = expectThrows(
|
||||||
Exception.class,
|
Exception.class,
|
||||||
() -> client().prepareSearch().setQuery(matchAllQuery()).setSize(1).setScroll(TimeValue.timeValueHours(2)).get()
|
() -> prepareSearch().setQuery(matchAllQuery()).setSize(1).setScroll(TimeValue.timeValueHours(2)).get()
|
||||||
);
|
);
|
||||||
IllegalArgumentException illegalArgumentException = (IllegalArgumentException) ExceptionsHelper.unwrap(
|
IllegalArgumentException illegalArgumentException = (IllegalArgumentException) ExceptionsHelper.unwrap(
|
||||||
exc,
|
exc,
|
||||||
|
@ -611,11 +585,7 @@ public class SearchScrollIT extends ESIntegTestCase {
|
||||||
assertNotNull(illegalArgumentException);
|
assertNotNull(illegalArgumentException);
|
||||||
assertThat(illegalArgumentException.getMessage(), containsString("Keep alive for request (2h) is too large"));
|
assertThat(illegalArgumentException.getMessage(), containsString("Keep alive for request (2h) is too large"));
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(matchAllQuery()).setSize(1).setScroll(TimeValue.timeValueMinutes(5)).get();
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.setSize(1)
|
|
||||||
.setScroll(TimeValue.timeValueMinutes(5))
|
|
||||||
.get();
|
|
||||||
assertNotNull(searchResponse.getScrollId());
|
assertNotNull(searchResponse.getScrollId());
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(2L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(2L));
|
||||||
assertThat(searchResponse.getHits().getHits().length, equalTo(1));
|
assertThat(searchResponse.getHits().getHits().length, equalTo(1));
|
||||||
|
|
|
@ -58,8 +58,7 @@ public class SearchScrollWithFailingNodesIT extends ESIntegTestCase {
|
||||||
indexRandom(false, writes);
|
indexRandom(false, writes);
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.setSize(10)
|
.setSize(10)
|
||||||
.setScroll(TimeValue.timeValueMinutes(1))
|
.setScroll(TimeValue.timeValueMinutes(1))
|
||||||
.get();
|
.get();
|
||||||
|
@ -75,7 +74,7 @@ public class SearchScrollWithFailingNodesIT extends ESIntegTestCase {
|
||||||
|
|
||||||
internalCluster().stopRandomNonMasterNode();
|
internalCluster().stopRandomNonMasterNode();
|
||||||
|
|
||||||
searchResponse = client().prepareSearch().setQuery(matchAllQuery()).setSize(10).setScroll(TimeValue.timeValueMinutes(1)).get();
|
searchResponse = prepareSearch().setQuery(matchAllQuery()).setSize(10).setScroll(TimeValue.timeValueMinutes(1)).get();
|
||||||
assertThat(searchResponse.getSuccessfulShards(), lessThan(searchResponse.getTotalShards()));
|
assertThat(searchResponse.getSuccessfulShards(), lessThan(searchResponse.getTotalShards()));
|
||||||
numHits = 0;
|
numHits = 0;
|
||||||
int numberOfSuccessfulShards = searchResponse.getSuccessfulShards();
|
int numberOfSuccessfulShards = searchResponse.getSuccessfulShards();
|
||||||
|
|
|
@ -143,12 +143,11 @@ public class SearchSliceIT extends ESIntegTestCase {
|
||||||
.addAliasAction(IndicesAliasesRequest.AliasActions.add().index("test").alias("alias3").routing("baz"))
|
.addAliasAction(IndicesAliasesRequest.AliasActions.add().index("test").alias("alias3").routing("baz"))
|
||||||
.get()
|
.get()
|
||||||
);
|
);
|
||||||
SearchResponse sr = client().prepareSearch("alias1", "alias3").setQuery(matchAllQuery()).setSize(0).get();
|
SearchResponse sr = prepareSearch("alias1", "alias3").setQuery(matchAllQuery()).setSize(0).get();
|
||||||
int numDocs = (int) sr.getHits().getTotalHits().value;
|
int numDocs = (int) sr.getHits().getTotalHits().value;
|
||||||
int max = randomIntBetween(2, numShards * 3);
|
int max = randomIntBetween(2, numShards * 3);
|
||||||
int fetchSize = randomIntBetween(10, 100);
|
int fetchSize = randomIntBetween(10, 100);
|
||||||
SearchRequestBuilder request = client().prepareSearch("alias1", "alias3")
|
SearchRequestBuilder request = prepareSearch("alias1", "alias3").setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.setScroll(new Scroll(TimeValue.timeValueSeconds(10)))
|
.setScroll(new Scroll(TimeValue.timeValueSeconds(10)))
|
||||||
.setSize(fetchSize)
|
.setSize(fetchSize)
|
||||||
.addSort(SortBuilders.fieldSort("_doc"));
|
.addSort(SortBuilders.fieldSort("_doc"));
|
||||||
|
@ -277,7 +276,7 @@ public class SearchSliceIT extends ESIntegTestCase {
|
||||||
setupIndex(0, 1);
|
setupIndex(0, 1);
|
||||||
SearchPhaseExecutionException exc = expectThrows(
|
SearchPhaseExecutionException exc = expectThrows(
|
||||||
SearchPhaseExecutionException.class,
|
SearchPhaseExecutionException.class,
|
||||||
() -> client().prepareSearch().setQuery(matchAllQuery()).slice(new SliceBuilder("invalid_random_int", 0, 10)).get()
|
() -> prepareSearch().setQuery(matchAllQuery()).slice(new SliceBuilder("invalid_random_int", 0, 10)).get()
|
||||||
);
|
);
|
||||||
Throwable rootCause = findRootCause(exc);
|
Throwable rootCause = findRootCause(exc);
|
||||||
assertThat(rootCause.getClass(), equalTo(SearchException.class));
|
assertThat(rootCause.getClass(), equalTo(SearchException.class));
|
||||||
|
|
|
@ -120,10 +120,9 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
refresh();
|
refresh();
|
||||||
// sort DESC
|
// sort DESC
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().addSort(
|
||||||
.addSort(new FieldSortBuilder("entry").order(SortOrder.DESC).unmappedType(useMapping ? null : "long"))
|
new FieldSortBuilder("entry").order(SortOrder.DESC).unmappedType(useMapping ? null : "long")
|
||||||
.setSize(10)
|
).setSize(10).get();
|
||||||
.get();
|
|
||||||
logClusterState();
|
logClusterState();
|
||||||
assertNoFailures(searchResponse);
|
assertNoFailures(searchResponse);
|
||||||
|
|
||||||
|
@ -134,10 +133,9 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
// sort ASC
|
// sort ASC
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().addSort(
|
||||||
.addSort(new FieldSortBuilder("entry").order(SortOrder.ASC).unmappedType(useMapping ? null : "long"))
|
new FieldSortBuilder("entry").order(SortOrder.ASC).unmappedType(useMapping ? null : "long")
|
||||||
.setSize(10)
|
).setSize(10).get();
|
||||||
.get();
|
|
||||||
logClusterState();
|
logClusterState();
|
||||||
assertNoFailures(searchResponse);
|
assertNoFailures(searchResponse);
|
||||||
|
|
||||||
|
@ -174,25 +172,20 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
docs += builders.size();
|
docs += builders.size();
|
||||||
builders.clear();
|
builders.clear();
|
||||||
}
|
}
|
||||||
SearchResponse allDocsResponse = client().prepareSearch()
|
SearchResponse allDocsResponse = prepareSearch().setQuery(
|
||||||
.setQuery(
|
QueryBuilders.boolQuery()
|
||||||
QueryBuilders.boolQuery()
|
.must(QueryBuilders.termQuery("foo", "bar"))
|
||||||
.must(QueryBuilders.termQuery("foo", "bar"))
|
.must(QueryBuilders.rangeQuery("timeUpdated").gte("2014/0" + randomIntBetween(1, 7) + "/01"))
|
||||||
.must(QueryBuilders.rangeQuery("timeUpdated").gte("2014/0" + randomIntBetween(1, 7) + "/01"))
|
).addSort(new FieldSortBuilder("timeUpdated").order(SortOrder.ASC).unmappedType("date")).setSize(docs).get();
|
||||||
)
|
|
||||||
.addSort(new FieldSortBuilder("timeUpdated").order(SortOrder.ASC).unmappedType("date"))
|
|
||||||
.setSize(docs)
|
|
||||||
.get();
|
|
||||||
assertNoFailures(allDocsResponse);
|
assertNoFailures(allDocsResponse);
|
||||||
|
|
||||||
final int numiters = randomIntBetween(1, 20);
|
final int numiters = randomIntBetween(1, 20);
|
||||||
for (int i = 0; i < numiters; i++) {
|
for (int i = 0; i < numiters; i++) {
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(
|
||||||
.setQuery(
|
QueryBuilders.boolQuery()
|
||||||
QueryBuilders.boolQuery()
|
.must(QueryBuilders.termQuery("foo", "bar"))
|
||||||
.must(QueryBuilders.termQuery("foo", "bar"))
|
.must(QueryBuilders.rangeQuery("timeUpdated").gte("2014/" + Strings.format("%02d", randomIntBetween(1, 7)) + "/01"))
|
||||||
.must(QueryBuilders.rangeQuery("timeUpdated").gte("2014/" + Strings.format("%02d", randomIntBetween(1, 7)) + "/01"))
|
)
|
||||||
)
|
|
||||||
.addSort(new FieldSortBuilder("timeUpdated").order(SortOrder.ASC).unmappedType("date"))
|
.addSort(new FieldSortBuilder("timeUpdated").order(SortOrder.ASC).unmappedType("date"))
|
||||||
.setSize(scaledRandomIntBetween(1, docs))
|
.setSize(scaledRandomIntBetween(1, docs))
|
||||||
.get();
|
.get();
|
||||||
|
@ -221,7 +214,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
);
|
);
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch().setQuery(matchAllQuery()).addSort("svalue", SortOrder.ASC).get();
|
SearchResponse searchResponse = prepareSearch().setQuery(matchAllQuery()).addSort("svalue", SortOrder.ASC).get();
|
||||||
|
|
||||||
assertThat(searchResponse.getHits().getMaxScore(), equalTo(Float.NaN));
|
assertThat(searchResponse.getHits().getMaxScore(), equalTo(Float.NaN));
|
||||||
for (SearchHit hit : searchResponse.getHits()) {
|
for (SearchHit hit : searchResponse.getHits()) {
|
||||||
|
@ -229,7 +222,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
// now check with score tracking
|
// now check with score tracking
|
||||||
searchResponse = client().prepareSearch().setQuery(matchAllQuery()).addSort("svalue", SortOrder.ASC).setTrackScores(true).get();
|
searchResponse = prepareSearch().setQuery(matchAllQuery()).addSort("svalue", SortOrder.ASC).setTrackScores(true).get();
|
||||||
|
|
||||||
assertThat(searchResponse.getHits().getMaxScore(), not(equalTo(Float.NaN)));
|
assertThat(searchResponse.getHits().getMaxScore(), not(equalTo(Float.NaN)));
|
||||||
for (SearchHit hit : searchResponse.getHits()) {
|
for (SearchHit hit : searchResponse.getHits()) {
|
||||||
|
@ -298,8 +291,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
if (sparseBytes.isEmpty() == false) {
|
if (sparseBytes.isEmpty() == false) {
|
||||||
int size = between(1, sparseBytes.size());
|
int size = between(1, sparseBytes.size());
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.setPostFilter(QueryBuilders.existsQuery("sparse_bytes"))
|
.setPostFilter(QueryBuilders.existsQuery("sparse_bytes"))
|
||||||
.setSize(size)
|
.setSize(size)
|
||||||
.addSort("sparse_bytes", SortOrder.ASC)
|
.addSort("sparse_bytes", SortOrder.ASC)
|
||||||
|
@ -575,11 +567,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
// STRING
|
// STRING
|
||||||
int size = 1 + random.nextInt(10);
|
int size = 1 + random.nextInt(10);
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(matchAllQuery()).setSize(size).addSort("str_value", SortOrder.ASC).get();
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.setSize(size)
|
|
||||||
.addSort("str_value", SortOrder.ASC)
|
|
||||||
.get();
|
|
||||||
assertHitCount(searchResponse, 10);
|
assertHitCount(searchResponse, 10);
|
||||||
assertThat(searchResponse.getHits().getHits().length, equalTo(size));
|
assertThat(searchResponse.getHits().getHits().length, equalTo(size));
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
|
@ -590,7 +578,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
size = 1 + random.nextInt(10);
|
size = 1 + random.nextInt(10);
|
||||||
searchResponse = client().prepareSearch().setQuery(matchAllQuery()).setSize(size).addSort("str_value", SortOrder.DESC).get();
|
searchResponse = prepareSearch().setQuery(matchAllQuery()).setSize(size).addSort("str_value", SortOrder.DESC).get();
|
||||||
|
|
||||||
assertHitCount(searchResponse, 10);
|
assertHitCount(searchResponse, 10);
|
||||||
assertThat(searchResponse.getHits().getHits().length, equalTo(size));
|
assertThat(searchResponse.getHits().getHits().length, equalTo(size));
|
||||||
|
@ -606,7 +594,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
|
|
||||||
// BYTE
|
// BYTE
|
||||||
size = 1 + random.nextInt(10);
|
size = 1 + random.nextInt(10);
|
||||||
searchResponse = client().prepareSearch().setQuery(matchAllQuery()).setSize(size).addSort("byte_value", SortOrder.ASC).get();
|
searchResponse = prepareSearch().setQuery(matchAllQuery()).setSize(size).addSort("byte_value", SortOrder.ASC).get();
|
||||||
|
|
||||||
assertHitCount(searchResponse, 10);
|
assertHitCount(searchResponse, 10);
|
||||||
assertThat(searchResponse.getHits().getHits().length, equalTo(size));
|
assertThat(searchResponse.getHits().getHits().length, equalTo(size));
|
||||||
|
@ -615,7 +603,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
assertThat(((Number) searchResponse.getHits().getAt(i).getSortValues()[0]).byteValue(), equalTo((byte) i));
|
assertThat(((Number) searchResponse.getHits().getAt(i).getSortValues()[0]).byteValue(), equalTo((byte) i));
|
||||||
}
|
}
|
||||||
size = 1 + random.nextInt(10);
|
size = 1 + random.nextInt(10);
|
||||||
searchResponse = client().prepareSearch().setQuery(matchAllQuery()).setSize(size).addSort("byte_value", SortOrder.DESC).get();
|
searchResponse = prepareSearch().setQuery(matchAllQuery()).setSize(size).addSort("byte_value", SortOrder.DESC).get();
|
||||||
|
|
||||||
assertHitCount(searchResponse, 10);
|
assertHitCount(searchResponse, 10);
|
||||||
assertThat(searchResponse.getHits().getHits().length, equalTo(size));
|
assertThat(searchResponse.getHits().getHits().length, equalTo(size));
|
||||||
|
@ -628,7 +616,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
|
|
||||||
// SHORT
|
// SHORT
|
||||||
size = 1 + random.nextInt(10);
|
size = 1 + random.nextInt(10);
|
||||||
searchResponse = client().prepareSearch().setQuery(matchAllQuery()).setSize(size).addSort("short_value", SortOrder.ASC).get();
|
searchResponse = prepareSearch().setQuery(matchAllQuery()).setSize(size).addSort("short_value", SortOrder.ASC).get();
|
||||||
|
|
||||||
assertHitCount(searchResponse, 10);
|
assertHitCount(searchResponse, 10);
|
||||||
assertThat(searchResponse.getHits().getHits().length, equalTo(size));
|
assertThat(searchResponse.getHits().getHits().length, equalTo(size));
|
||||||
|
@ -637,7 +625,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
assertThat(((Number) searchResponse.getHits().getAt(i).getSortValues()[0]).shortValue(), equalTo((short) i));
|
assertThat(((Number) searchResponse.getHits().getAt(i).getSortValues()[0]).shortValue(), equalTo((short) i));
|
||||||
}
|
}
|
||||||
size = 1 + random.nextInt(10);
|
size = 1 + random.nextInt(10);
|
||||||
searchResponse = client().prepareSearch().setQuery(matchAllQuery()).setSize(size).addSort("short_value", SortOrder.DESC).get();
|
searchResponse = prepareSearch().setQuery(matchAllQuery()).setSize(size).addSort("short_value", SortOrder.DESC).get();
|
||||||
|
|
||||||
assertHitCount(searchResponse, 10);
|
assertHitCount(searchResponse, 10);
|
||||||
assertThat(searchResponse.getHits().getHits().length, equalTo(size));
|
assertThat(searchResponse.getHits().getHits().length, equalTo(size));
|
||||||
|
@ -650,7 +638,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
|
|
||||||
// INTEGER
|
// INTEGER
|
||||||
size = 1 + random.nextInt(10);
|
size = 1 + random.nextInt(10);
|
||||||
searchResponse = client().prepareSearch().setQuery(matchAllQuery()).setSize(size).addSort("integer_value", SortOrder.ASC).get();
|
searchResponse = prepareSearch().setQuery(matchAllQuery()).setSize(size).addSort("integer_value", SortOrder.ASC).get();
|
||||||
|
|
||||||
assertHitCount(searchResponse, 10);
|
assertHitCount(searchResponse, 10);
|
||||||
assertThat(searchResponse.getHits().getHits().length, equalTo(size));
|
assertThat(searchResponse.getHits().getHits().length, equalTo(size));
|
||||||
|
@ -661,7 +649,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
|
|
||||||
assertThat(searchResponse.toString(), not(containsString("error")));
|
assertThat(searchResponse.toString(), not(containsString("error")));
|
||||||
size = 1 + random.nextInt(10);
|
size = 1 + random.nextInt(10);
|
||||||
searchResponse = client().prepareSearch().setQuery(matchAllQuery()).setSize(size).addSort("integer_value", SortOrder.DESC).get();
|
searchResponse = prepareSearch().setQuery(matchAllQuery()).setSize(size).addSort("integer_value", SortOrder.DESC).get();
|
||||||
|
|
||||||
assertHitCount(searchResponse, 10);
|
assertHitCount(searchResponse, 10);
|
||||||
assertThat(searchResponse.getHits().getHits().length, equalTo(size));
|
assertThat(searchResponse.getHits().getHits().length, equalTo(size));
|
||||||
|
@ -674,7 +662,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
|
|
||||||
// LONG
|
// LONG
|
||||||
size = 1 + random.nextInt(10);
|
size = 1 + random.nextInt(10);
|
||||||
searchResponse = client().prepareSearch().setQuery(matchAllQuery()).setSize(size).addSort("long_value", SortOrder.ASC).get();
|
searchResponse = prepareSearch().setQuery(matchAllQuery()).setSize(size).addSort("long_value", SortOrder.ASC).get();
|
||||||
|
|
||||||
assertHitCount(searchResponse, 10);
|
assertHitCount(searchResponse, 10);
|
||||||
assertThat(searchResponse.getHits().getHits().length, equalTo(size));
|
assertThat(searchResponse.getHits().getHits().length, equalTo(size));
|
||||||
|
@ -685,7 +673,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
|
|
||||||
assertThat(searchResponse.toString(), not(containsString("error")));
|
assertThat(searchResponse.toString(), not(containsString("error")));
|
||||||
size = 1 + random.nextInt(10);
|
size = 1 + random.nextInt(10);
|
||||||
searchResponse = client().prepareSearch().setQuery(matchAllQuery()).setSize(size).addSort("long_value", SortOrder.DESC).get();
|
searchResponse = prepareSearch().setQuery(matchAllQuery()).setSize(size).addSort("long_value", SortOrder.DESC).get();
|
||||||
assertHitCount(searchResponse, 10L);
|
assertHitCount(searchResponse, 10L);
|
||||||
assertHitCount(searchResponse, 10);
|
assertHitCount(searchResponse, 10);
|
||||||
assertThat(searchResponse.getHits().getHits().length, equalTo(size));
|
assertThat(searchResponse.getHits().getHits().length, equalTo(size));
|
||||||
|
@ -698,7 +686,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
|
|
||||||
// FLOAT
|
// FLOAT
|
||||||
size = 1 + random.nextInt(10);
|
size = 1 + random.nextInt(10);
|
||||||
searchResponse = client().prepareSearch().setQuery(matchAllQuery()).setSize(size).addSort("float_value", SortOrder.ASC).get();
|
searchResponse = prepareSearch().setQuery(matchAllQuery()).setSize(size).addSort("float_value", SortOrder.ASC).get();
|
||||||
|
|
||||||
assertHitCount(searchResponse, 10L);
|
assertHitCount(searchResponse, 10L);
|
||||||
assertThat(searchResponse.getHits().getHits().length, equalTo(size));
|
assertThat(searchResponse.getHits().getHits().length, equalTo(size));
|
||||||
|
@ -709,7 +697,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
|
|
||||||
assertThat(searchResponse.toString(), not(containsString("error")));
|
assertThat(searchResponse.toString(), not(containsString("error")));
|
||||||
size = 1 + random.nextInt(10);
|
size = 1 + random.nextInt(10);
|
||||||
searchResponse = client().prepareSearch().setQuery(matchAllQuery()).setSize(size).addSort("float_value", SortOrder.DESC).get();
|
searchResponse = prepareSearch().setQuery(matchAllQuery()).setSize(size).addSort("float_value", SortOrder.DESC).get();
|
||||||
|
|
||||||
assertHitCount(searchResponse, 10);
|
assertHitCount(searchResponse, 10);
|
||||||
assertThat(searchResponse.getHits().getHits().length, equalTo(size));
|
assertThat(searchResponse.getHits().getHits().length, equalTo(size));
|
||||||
|
@ -722,7 +710,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
|
|
||||||
// DOUBLE
|
// DOUBLE
|
||||||
size = 1 + random.nextInt(10);
|
size = 1 + random.nextInt(10);
|
||||||
searchResponse = client().prepareSearch().setQuery(matchAllQuery()).setSize(size).addSort("double_value", SortOrder.ASC).get();
|
searchResponse = prepareSearch().setQuery(matchAllQuery()).setSize(size).addSort("double_value", SortOrder.ASC).get();
|
||||||
|
|
||||||
assertHitCount(searchResponse, 10L);
|
assertHitCount(searchResponse, 10L);
|
||||||
assertThat(searchResponse.getHits().getHits().length, equalTo(size));
|
assertThat(searchResponse.getHits().getHits().length, equalTo(size));
|
||||||
|
@ -733,7 +721,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
|
|
||||||
assertThat(searchResponse.toString(), not(containsString("error")));
|
assertThat(searchResponse.toString(), not(containsString("error")));
|
||||||
size = 1 + random.nextInt(10);
|
size = 1 + random.nextInt(10);
|
||||||
searchResponse = client().prepareSearch().setQuery(matchAllQuery()).setSize(size).addSort("double_value", SortOrder.DESC).get();
|
searchResponse = prepareSearch().setQuery(matchAllQuery()).setSize(size).addSort("double_value", SortOrder.DESC).get();
|
||||||
|
|
||||||
assertHitCount(searchResponse, 10L);
|
assertHitCount(searchResponse, 10L);
|
||||||
assertThat(searchResponse.getHits().getHits().length, equalTo(size));
|
assertThat(searchResponse.getHits().getHits().length, equalTo(size));
|
||||||
|
@ -780,8 +768,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
logger.info("--> sort with no missing (same as missing _last)");
|
logger.info("--> sort with no missing (same as missing _last)");
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addSort(SortBuilders.fieldSort("i_value").order(SortOrder.ASC))
|
.addSort(SortBuilders.fieldSort("i_value").order(SortOrder.ASC))
|
||||||
.get();
|
.get();
|
||||||
assertNoFailures(searchResponse);
|
assertNoFailures(searchResponse);
|
||||||
|
@ -792,8 +779,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
assertThat(searchResponse.getHits().getAt(2).getId(), equalTo("2"));
|
assertThat(searchResponse.getHits().getAt(2).getId(), equalTo("2"));
|
||||||
|
|
||||||
logger.info("--> sort with missing _last");
|
logger.info("--> sort with missing _last");
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addSort(SortBuilders.fieldSort("i_value").order(SortOrder.ASC).missing("_last"))
|
.addSort(SortBuilders.fieldSort("i_value").order(SortOrder.ASC).missing("_last"))
|
||||||
.get();
|
.get();
|
||||||
assertNoFailures(searchResponse);
|
assertNoFailures(searchResponse);
|
||||||
|
@ -804,8 +790,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
assertThat(searchResponse.getHits().getAt(2).getId(), equalTo("2"));
|
assertThat(searchResponse.getHits().getAt(2).getId(), equalTo("2"));
|
||||||
|
|
||||||
logger.info("--> sort with missing _first");
|
logger.info("--> sort with missing _first");
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addSort(SortBuilders.fieldSort("i_value").order(SortOrder.ASC).missing("_first"))
|
.addSort(SortBuilders.fieldSort("i_value").order(SortOrder.ASC).missing("_first"))
|
||||||
.get();
|
.get();
|
||||||
assertNoFailures(searchResponse);
|
assertNoFailures(searchResponse);
|
||||||
|
@ -855,8 +840,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("--> sort with no missing (same as missing _last)");
|
logger.info("--> sort with no missing (same as missing _last)");
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addSort(SortBuilders.fieldSort("value").order(SortOrder.ASC))
|
.addSort(SortBuilders.fieldSort("value").order(SortOrder.ASC))
|
||||||
.get();
|
.get();
|
||||||
assertThat(Arrays.toString(searchResponse.getShardFailures()), searchResponse.getFailedShards(), equalTo(0));
|
assertThat(Arrays.toString(searchResponse.getShardFailures()), searchResponse.getFailedShards(), equalTo(0));
|
||||||
|
@ -867,8 +851,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
assertThat(searchResponse.getHits().getAt(2).getId(), equalTo("2"));
|
assertThat(searchResponse.getHits().getAt(2).getId(), equalTo("2"));
|
||||||
|
|
||||||
logger.info("--> sort with missing _last");
|
logger.info("--> sort with missing _last");
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addSort(SortBuilders.fieldSort("value").order(SortOrder.ASC).missing("_last"))
|
.addSort(SortBuilders.fieldSort("value").order(SortOrder.ASC).missing("_last"))
|
||||||
.get();
|
.get();
|
||||||
assertThat(Arrays.toString(searchResponse.getShardFailures()), searchResponse.getFailedShards(), equalTo(0));
|
assertThat(Arrays.toString(searchResponse.getShardFailures()), searchResponse.getFailedShards(), equalTo(0));
|
||||||
|
@ -879,8 +862,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
assertThat(searchResponse.getHits().getAt(2).getId(), equalTo("2"));
|
assertThat(searchResponse.getHits().getAt(2).getId(), equalTo("2"));
|
||||||
|
|
||||||
logger.info("--> sort with missing _first");
|
logger.info("--> sort with missing _first");
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addSort(SortBuilders.fieldSort("value").order(SortOrder.ASC).missing("_first"))
|
.addSort(SortBuilders.fieldSort("value").order(SortOrder.ASC).missing("_first"))
|
||||||
.get();
|
.get();
|
||||||
assertThat(Arrays.toString(searchResponse.getShardFailures()), searchResponse.getFailedShards(), equalTo(0));
|
assertThat(Arrays.toString(searchResponse.getShardFailures()), searchResponse.getFailedShards(), equalTo(0));
|
||||||
|
@ -891,8 +873,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
assertThat(searchResponse.getHits().getAt(2).getId(), equalTo("3"));
|
assertThat(searchResponse.getHits().getAt(2).getId(), equalTo("3"));
|
||||||
|
|
||||||
logger.info("--> sort with missing b");
|
logger.info("--> sort with missing b");
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addSort(SortBuilders.fieldSort("value").order(SortOrder.ASC).missing("b"))
|
.addSort(SortBuilders.fieldSort("value").order(SortOrder.ASC).missing("b"))
|
||||||
.get();
|
.get();
|
||||||
assertThat(Arrays.toString(searchResponse.getShardFailures()), searchResponse.getFailedShards(), equalTo(0));
|
assertThat(Arrays.toString(searchResponse.getShardFailures()), searchResponse.getFailedShards(), equalTo(0));
|
||||||
|
@ -1036,7 +1017,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
|
|
||||||
logger.info("--> sort with an unmapped field, verify it fails");
|
logger.info("--> sort with an unmapped field, verify it fails");
|
||||||
try {
|
try {
|
||||||
SearchResponse result = client().prepareSearch().setQuery(matchAllQuery()).addSort(SortBuilders.fieldSort("kkk")).get();
|
SearchResponse result = prepareSearch().setQuery(matchAllQuery()).addSort(SortBuilders.fieldSort("kkk")).get();
|
||||||
assertThat("Expected exception but returned with", result, nullValue());
|
assertThat("Expected exception but returned with", result, nullValue());
|
||||||
} catch (SearchPhaseExecutionException e) {
|
} catch (SearchPhaseExecutionException e) {
|
||||||
// we check that it's a parse failure rather than a different shard failure
|
// we check that it's a parse failure rather than a different shard failure
|
||||||
|
@ -1045,12 +1026,11 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assertNoFailures(client().prepareSearch().setQuery(matchAllQuery()).addSort(SortBuilders.fieldSort("kkk").unmappedType("keyword")));
|
assertNoFailures(prepareSearch().setQuery(matchAllQuery()).addSort(SortBuilders.fieldSort("kkk").unmappedType("keyword")));
|
||||||
|
|
||||||
// nested field
|
// nested field
|
||||||
assertNoFailures(
|
assertNoFailures(
|
||||||
client().prepareSearch()
|
prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addSort(
|
.addSort(
|
||||||
SortBuilders.fieldSort("nested.foo")
|
SortBuilders.fieldSort("nested.foo")
|
||||||
.unmappedType("keyword")
|
.unmappedType("keyword")
|
||||||
|
@ -1060,8 +1040,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
|
|
||||||
// nestedQuery
|
// nestedQuery
|
||||||
assertNoFailures(
|
assertNoFailures(
|
||||||
client().prepareSearch()
|
prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addSort(
|
.addSort(
|
||||||
SortBuilders.fieldSort("nested.foo")
|
SortBuilders.fieldSort("nested.foo")
|
||||||
.unmappedType("keyword")
|
.unmappedType("keyword")
|
||||||
|
@ -1150,11 +1129,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
|
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(matchAllQuery()).setSize(10).addSort("long_values", SortOrder.ASC).get();
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.setSize(10)
|
|
||||||
.addSort("long_values", SortOrder.ASC)
|
|
||||||
.get();
|
|
||||||
|
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(3L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(3L));
|
||||||
assertThat(searchResponse.getHits().getHits().length, equalTo(3));
|
assertThat(searchResponse.getHits().getHits().length, equalTo(3));
|
||||||
|
@ -1168,7 +1143,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
assertThat(searchResponse.getHits().getAt(2).getId(), equalTo(Integer.toString(2)));
|
assertThat(searchResponse.getHits().getAt(2).getId(), equalTo(Integer.toString(2)));
|
||||||
assertThat(((Number) searchResponse.getHits().getAt(2).getSortValues()[0]).longValue(), equalTo(7L));
|
assertThat(((Number) searchResponse.getHits().getAt(2).getSortValues()[0]).longValue(), equalTo(7L));
|
||||||
|
|
||||||
searchResponse = client().prepareSearch().setQuery(matchAllQuery()).setSize(10).addSort("long_values", SortOrder.DESC).get();
|
searchResponse = prepareSearch().setQuery(matchAllQuery()).setSize(10).addSort("long_values", SortOrder.DESC).get();
|
||||||
|
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(3L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(3L));
|
||||||
assertThat(searchResponse.getHits().getHits().length, equalTo(3));
|
assertThat(searchResponse.getHits().getHits().length, equalTo(3));
|
||||||
|
@ -1182,8 +1157,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
assertThat(searchResponse.getHits().getAt(2).getId(), equalTo(Integer.toString(3)));
|
assertThat(searchResponse.getHits().getAt(2).getId(), equalTo(Integer.toString(3)));
|
||||||
assertThat(((Number) searchResponse.getHits().getAt(2).getSortValues()[0]).longValue(), equalTo(3L));
|
assertThat(((Number) searchResponse.getHits().getAt(2).getSortValues()[0]).longValue(), equalTo(3L));
|
||||||
|
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.setSize(10)
|
.setSize(10)
|
||||||
.addSort(SortBuilders.fieldSort("long_values").order(SortOrder.DESC).sortMode(SortMode.SUM))
|
.addSort(SortBuilders.fieldSort("long_values").order(SortOrder.DESC).sortMode(SortMode.SUM))
|
||||||
.get();
|
.get();
|
||||||
|
@ -1200,8 +1174,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
assertThat(searchResponse.getHits().getAt(2).getId(), equalTo(Integer.toString(3)));
|
assertThat(searchResponse.getHits().getAt(2).getId(), equalTo(Integer.toString(3)));
|
||||||
assertThat(((Number) searchResponse.getHits().getAt(2).getSortValues()[0]).longValue(), equalTo(2L));
|
assertThat(((Number) searchResponse.getHits().getAt(2).getSortValues()[0]).longValue(), equalTo(2L));
|
||||||
|
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.setSize(10)
|
.setSize(10)
|
||||||
.addSort(SortBuilders.fieldSort("long_values").order(SortOrder.DESC).sortMode(SortMode.AVG))
|
.addSort(SortBuilders.fieldSort("long_values").order(SortOrder.DESC).sortMode(SortMode.AVG))
|
||||||
.get();
|
.get();
|
||||||
|
@ -1218,8 +1191,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
assertThat(searchResponse.getHits().getAt(2).getId(), equalTo(Integer.toString(3)));
|
assertThat(searchResponse.getHits().getAt(2).getId(), equalTo(Integer.toString(3)));
|
||||||
assertThat(((Number) searchResponse.getHits().getAt(2).getSortValues()[0]).longValue(), equalTo(1L));
|
assertThat(((Number) searchResponse.getHits().getAt(2).getSortValues()[0]).longValue(), equalTo(1L));
|
||||||
|
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.setSize(10)
|
.setSize(10)
|
||||||
.addSort(SortBuilders.fieldSort("long_values").order(SortOrder.DESC).sortMode(SortMode.MEDIAN))
|
.addSort(SortBuilders.fieldSort("long_values").order(SortOrder.DESC).sortMode(SortMode.MEDIAN))
|
||||||
.get();
|
.get();
|
||||||
|
@ -1236,7 +1208,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
assertThat(searchResponse.getHits().getAt(2).getId(), equalTo(Integer.toString(3)));
|
assertThat(searchResponse.getHits().getAt(2).getId(), equalTo(Integer.toString(3)));
|
||||||
assertThat(((Number) searchResponse.getHits().getAt(2).getSortValues()[0]).longValue(), equalTo(2L));
|
assertThat(((Number) searchResponse.getHits().getAt(2).getSortValues()[0]).longValue(), equalTo(2L));
|
||||||
|
|
||||||
searchResponse = client().prepareSearch().setQuery(matchAllQuery()).setSize(10).addSort("int_values", SortOrder.ASC).get();
|
searchResponse = prepareSearch().setQuery(matchAllQuery()).setSize(10).addSort("int_values", SortOrder.ASC).get();
|
||||||
|
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(3L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(3L));
|
||||||
assertThat(searchResponse.getHits().getHits().length, equalTo(3));
|
assertThat(searchResponse.getHits().getHits().length, equalTo(3));
|
||||||
|
@ -1250,7 +1222,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
assertThat(searchResponse.getHits().getAt(2).getId(), equalTo(Integer.toString(2)));
|
assertThat(searchResponse.getHits().getAt(2).getId(), equalTo(Integer.toString(2)));
|
||||||
assertThat(((Number) searchResponse.getHits().getAt(2).getSortValues()[0]).intValue(), equalTo(7));
|
assertThat(((Number) searchResponse.getHits().getAt(2).getSortValues()[0]).intValue(), equalTo(7));
|
||||||
|
|
||||||
searchResponse = client().prepareSearch().setQuery(matchAllQuery()).setSize(10).addSort("int_values", SortOrder.DESC).get();
|
searchResponse = prepareSearch().setQuery(matchAllQuery()).setSize(10).addSort("int_values", SortOrder.DESC).get();
|
||||||
|
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(3L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(3L));
|
||||||
assertThat(searchResponse.getHits().getHits().length, equalTo(3));
|
assertThat(searchResponse.getHits().getHits().length, equalTo(3));
|
||||||
|
@ -1264,7 +1236,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
assertThat(searchResponse.getHits().getAt(2).getId(), equalTo(Integer.toString(3)));
|
assertThat(searchResponse.getHits().getAt(2).getId(), equalTo(Integer.toString(3)));
|
||||||
assertThat(((Number) searchResponse.getHits().getAt(2).getSortValues()[0]).intValue(), equalTo(3));
|
assertThat(((Number) searchResponse.getHits().getAt(2).getSortValues()[0]).intValue(), equalTo(3));
|
||||||
|
|
||||||
searchResponse = client().prepareSearch().setQuery(matchAllQuery()).setSize(10).addSort("short_values", SortOrder.ASC).get();
|
searchResponse = prepareSearch().setQuery(matchAllQuery()).setSize(10).addSort("short_values", SortOrder.ASC).get();
|
||||||
|
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(3L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(3L));
|
||||||
assertThat(searchResponse.getHits().getHits().length, equalTo(3));
|
assertThat(searchResponse.getHits().getHits().length, equalTo(3));
|
||||||
|
@ -1278,7 +1250,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
assertThat(searchResponse.getHits().getAt(2).getId(), equalTo(Integer.toString(2)));
|
assertThat(searchResponse.getHits().getAt(2).getId(), equalTo(Integer.toString(2)));
|
||||||
assertThat(((Number) searchResponse.getHits().getAt(2).getSortValues()[0]).intValue(), equalTo(7));
|
assertThat(((Number) searchResponse.getHits().getAt(2).getSortValues()[0]).intValue(), equalTo(7));
|
||||||
|
|
||||||
searchResponse = client().prepareSearch().setQuery(matchAllQuery()).setSize(10).addSort("short_values", SortOrder.DESC).get();
|
searchResponse = prepareSearch().setQuery(matchAllQuery()).setSize(10).addSort("short_values", SortOrder.DESC).get();
|
||||||
|
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(3L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(3L));
|
||||||
assertThat(searchResponse.getHits().getHits().length, equalTo(3));
|
assertThat(searchResponse.getHits().getHits().length, equalTo(3));
|
||||||
|
@ -1292,7 +1264,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
assertThat(searchResponse.getHits().getAt(2).getId(), equalTo(Integer.toString(3)));
|
assertThat(searchResponse.getHits().getAt(2).getId(), equalTo(Integer.toString(3)));
|
||||||
assertThat(((Number) searchResponse.getHits().getAt(2).getSortValues()[0]).intValue(), equalTo(3));
|
assertThat(((Number) searchResponse.getHits().getAt(2).getSortValues()[0]).intValue(), equalTo(3));
|
||||||
|
|
||||||
searchResponse = client().prepareSearch().setQuery(matchAllQuery()).setSize(10).addSort("byte_values", SortOrder.ASC).get();
|
searchResponse = prepareSearch().setQuery(matchAllQuery()).setSize(10).addSort("byte_values", SortOrder.ASC).get();
|
||||||
|
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(3L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(3L));
|
||||||
assertThat(searchResponse.getHits().getHits().length, equalTo(3));
|
assertThat(searchResponse.getHits().getHits().length, equalTo(3));
|
||||||
|
@ -1306,7 +1278,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
assertThat(searchResponse.getHits().getAt(2).getId(), equalTo(Integer.toString(2)));
|
assertThat(searchResponse.getHits().getAt(2).getId(), equalTo(Integer.toString(2)));
|
||||||
assertThat(((Number) searchResponse.getHits().getAt(2).getSortValues()[0]).intValue(), equalTo(7));
|
assertThat(((Number) searchResponse.getHits().getAt(2).getSortValues()[0]).intValue(), equalTo(7));
|
||||||
|
|
||||||
searchResponse = client().prepareSearch().setQuery(matchAllQuery()).setSize(10).addSort("byte_values", SortOrder.DESC).get();
|
searchResponse = prepareSearch().setQuery(matchAllQuery()).setSize(10).addSort("byte_values", SortOrder.DESC).get();
|
||||||
|
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(3L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(3L));
|
||||||
assertThat(searchResponse.getHits().getHits().length, equalTo(3));
|
assertThat(searchResponse.getHits().getHits().length, equalTo(3));
|
||||||
|
@ -1320,7 +1292,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
assertThat(searchResponse.getHits().getAt(2).getId(), equalTo(Integer.toString(3)));
|
assertThat(searchResponse.getHits().getAt(2).getId(), equalTo(Integer.toString(3)));
|
||||||
assertThat(((Number) searchResponse.getHits().getAt(2).getSortValues()[0]).intValue(), equalTo(3));
|
assertThat(((Number) searchResponse.getHits().getAt(2).getSortValues()[0]).intValue(), equalTo(3));
|
||||||
|
|
||||||
searchResponse = client().prepareSearch().setQuery(matchAllQuery()).setSize(10).addSort("float_values", SortOrder.ASC).get();
|
searchResponse = prepareSearch().setQuery(matchAllQuery()).setSize(10).addSort("float_values", SortOrder.ASC).get();
|
||||||
|
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(3L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(3L));
|
||||||
assertThat(searchResponse.getHits().getHits().length, equalTo(3));
|
assertThat(searchResponse.getHits().getHits().length, equalTo(3));
|
||||||
|
@ -1334,7 +1306,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
assertThat(searchResponse.getHits().getAt(2).getId(), equalTo(Integer.toString(2)));
|
assertThat(searchResponse.getHits().getAt(2).getId(), equalTo(Integer.toString(2)));
|
||||||
assertThat(((Number) searchResponse.getHits().getAt(2).getSortValues()[0]).floatValue(), equalTo(7f));
|
assertThat(((Number) searchResponse.getHits().getAt(2).getSortValues()[0]).floatValue(), equalTo(7f));
|
||||||
|
|
||||||
searchResponse = client().prepareSearch().setQuery(matchAllQuery()).setSize(10).addSort("float_values", SortOrder.DESC).get();
|
searchResponse = prepareSearch().setQuery(matchAllQuery()).setSize(10).addSort("float_values", SortOrder.DESC).get();
|
||||||
|
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(3L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(3L));
|
||||||
assertThat(searchResponse.getHits().getHits().length, equalTo(3));
|
assertThat(searchResponse.getHits().getHits().length, equalTo(3));
|
||||||
|
@ -1348,7 +1320,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
assertThat(searchResponse.getHits().getAt(2).getId(), equalTo(Integer.toString(3)));
|
assertThat(searchResponse.getHits().getAt(2).getId(), equalTo(Integer.toString(3)));
|
||||||
assertThat(((Number) searchResponse.getHits().getAt(2).getSortValues()[0]).floatValue(), equalTo(3f));
|
assertThat(((Number) searchResponse.getHits().getAt(2).getSortValues()[0]).floatValue(), equalTo(3f));
|
||||||
|
|
||||||
searchResponse = client().prepareSearch().setQuery(matchAllQuery()).setSize(10).addSort("double_values", SortOrder.ASC).get();
|
searchResponse = prepareSearch().setQuery(matchAllQuery()).setSize(10).addSort("double_values", SortOrder.ASC).get();
|
||||||
|
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(3L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(3L));
|
||||||
assertThat(searchResponse.getHits().getHits().length, equalTo(3));
|
assertThat(searchResponse.getHits().getHits().length, equalTo(3));
|
||||||
|
@ -1362,7 +1334,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
assertThat(searchResponse.getHits().getAt(2).getId(), equalTo(Integer.toString(2)));
|
assertThat(searchResponse.getHits().getAt(2).getId(), equalTo(Integer.toString(2)));
|
||||||
assertThat(((Number) searchResponse.getHits().getAt(2).getSortValues()[0]).doubleValue(), equalTo(7d));
|
assertThat(((Number) searchResponse.getHits().getAt(2).getSortValues()[0]).doubleValue(), equalTo(7d));
|
||||||
|
|
||||||
searchResponse = client().prepareSearch().setQuery(matchAllQuery()).setSize(10).addSort("double_values", SortOrder.DESC).get();
|
searchResponse = prepareSearch().setQuery(matchAllQuery()).setSize(10).addSort("double_values", SortOrder.DESC).get();
|
||||||
|
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(3L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(3L));
|
||||||
assertThat(searchResponse.getHits().getHits().length, equalTo(3));
|
assertThat(searchResponse.getHits().getHits().length, equalTo(3));
|
||||||
|
@ -1376,7 +1348,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
assertThat(searchResponse.getHits().getAt(2).getId(), equalTo(Integer.toString(3)));
|
assertThat(searchResponse.getHits().getAt(2).getId(), equalTo(Integer.toString(3)));
|
||||||
assertThat(((Number) searchResponse.getHits().getAt(2).getSortValues()[0]).doubleValue(), equalTo(3d));
|
assertThat(((Number) searchResponse.getHits().getAt(2).getSortValues()[0]).doubleValue(), equalTo(3d));
|
||||||
|
|
||||||
searchResponse = client().prepareSearch().setQuery(matchAllQuery()).setSize(10).addSort("string_values", SortOrder.ASC).get();
|
searchResponse = prepareSearch().setQuery(matchAllQuery()).setSize(10).addSort("string_values", SortOrder.ASC).get();
|
||||||
|
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(3L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(3L));
|
||||||
assertThat(searchResponse.getHits().getHits().length, equalTo(3));
|
assertThat(searchResponse.getHits().getHits().length, equalTo(3));
|
||||||
|
@ -1390,7 +1362,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
assertThat(searchResponse.getHits().getAt(2).getId(), equalTo(Integer.toString(2)));
|
assertThat(searchResponse.getHits().getAt(2).getId(), equalTo(Integer.toString(2)));
|
||||||
assertThat(searchResponse.getHits().getAt(2).getSortValues()[0], equalTo("07"));
|
assertThat(searchResponse.getHits().getAt(2).getSortValues()[0], equalTo("07"));
|
||||||
|
|
||||||
searchResponse = client().prepareSearch().setQuery(matchAllQuery()).setSize(10).addSort("string_values", SortOrder.DESC).get();
|
searchResponse = prepareSearch().setQuery(matchAllQuery()).setSize(10).addSort("string_values", SortOrder.DESC).get();
|
||||||
|
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(3L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(3L));
|
||||||
assertThat(searchResponse.getHits().getHits().length, equalTo(3));
|
assertThat(searchResponse.getHits().getHits().length, equalTo(3));
|
||||||
|
@ -1427,11 +1399,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
refresh();
|
refresh();
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(matchAllQuery()).setSize(3).addSort("string_values", SortOrder.DESC).get();
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.setSize(3)
|
|
||||||
.addSort("string_values", SortOrder.DESC)
|
|
||||||
.get();
|
|
||||||
|
|
||||||
assertThat(searchResponse.getHits().getHits().length, equalTo(1));
|
assertThat(searchResponse.getHits().getHits().length, equalTo(1));
|
||||||
|
|
||||||
|
@ -1450,7 +1418,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
searchResponse = client().prepareSearch().setQuery(matchAllQuery()).setSize(2).addSort("string_values", SortOrder.DESC).get();
|
searchResponse = prepareSearch().setQuery(matchAllQuery()).setSize(2).addSort("string_values", SortOrder.DESC).get();
|
||||||
|
|
||||||
assertThat(searchResponse.getHits().getHits().length, equalTo(2));
|
assertThat(searchResponse.getHits().getHits().length, equalTo(2));
|
||||||
|
|
||||||
|
@ -1472,7 +1440,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
searchResponse = client().prepareSearch().setQuery(matchAllQuery()).setSize(3).addSort("string_values", SortOrder.DESC).get();
|
searchResponse = prepareSearch().setQuery(matchAllQuery()).setSize(3).addSort("string_values", SortOrder.DESC).get();
|
||||||
|
|
||||||
assertThat(searchResponse.getHits().getHits().length, equalTo(3));
|
assertThat(searchResponse.getHits().getHits().length, equalTo(3));
|
||||||
|
|
||||||
|
@ -1493,7 +1461,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
searchResponse = client().prepareSearch().setQuery(matchAllQuery()).setSize(3).addSort("string_values", SortOrder.DESC).get();
|
searchResponse = prepareSearch().setQuery(matchAllQuery()).setSize(3).addSort("string_values", SortOrder.DESC).get();
|
||||||
|
|
||||||
assertThat(searchResponse.getHits().getHits().length, equalTo(3));
|
assertThat(searchResponse.getHits().getHits().length, equalTo(3));
|
||||||
|
|
||||||
|
@ -1520,8 +1488,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
indexRandom(true, indexReqs);
|
indexRandom(true, indexReqs);
|
||||||
|
|
||||||
SortOrder order = randomFrom(SortOrder.values());
|
SortOrder order = randomFrom(SortOrder.values());
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.setSize(randomIntBetween(1, numDocs + 5))
|
.setSize(randomIntBetween(1, numDocs + 5))
|
||||||
.addSort("_id", order)
|
.addSort("_id", order)
|
||||||
.get();
|
.get();
|
||||||
|
@ -1621,8 +1588,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
|
|
||||||
// We sort on nested field
|
// We sort on nested field
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addSort(SortBuilders.fieldSort("nested.foo").setNestedSort(new NestedSortBuilder("nested")).order(SortOrder.DESC))
|
.addSort(SortBuilders.fieldSort("nested.foo").setNestedSort(new NestedSortBuilder("nested")).order(SortOrder.DESC))
|
||||||
.get();
|
.get();
|
||||||
assertNoFailures(searchResponse);
|
assertNoFailures(searchResponse);
|
||||||
|
@ -1634,8 +1600,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
assertThat(hits[1].getSortValues()[0], is("bar"));
|
assertThat(hits[1].getSortValues()[0], is("bar"));
|
||||||
|
|
||||||
// We sort on nested fields with max_children limit
|
// We sort on nested fields with max_children limit
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addSort(
|
.addSort(
|
||||||
SortBuilders.fieldSort("nested.foo").setNestedSort(new NestedSortBuilder("nested").setMaxChildren(1)).order(SortOrder.DESC)
|
SortBuilders.fieldSort("nested.foo").setNestedSort(new NestedSortBuilder("nested").setMaxChildren(1)).order(SortOrder.DESC)
|
||||||
)
|
)
|
||||||
|
@ -1651,8 +1616,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
{
|
{
|
||||||
SearchPhaseExecutionException exc = expectThrows(
|
SearchPhaseExecutionException exc = expectThrows(
|
||||||
SearchPhaseExecutionException.class,
|
SearchPhaseExecutionException.class,
|
||||||
() -> client().prepareSearch()
|
() -> prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addSort(
|
.addSort(
|
||||||
SortBuilders.fieldSort("nested.bar.foo")
|
SortBuilders.fieldSort("nested.bar.foo")
|
||||||
.setNestedSort(
|
.setNestedSort(
|
||||||
|
@ -1666,8 +1630,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
// We sort on nested sub field
|
// We sort on nested sub field
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addSort(SortBuilders.fieldSort("nested.foo.sub").setNestedSort(new NestedSortBuilder("nested")).order(SortOrder.DESC))
|
.addSort(SortBuilders.fieldSort("nested.foo.sub").setNestedSort(new NestedSortBuilder("nested")).order(SortOrder.DESC))
|
||||||
.get();
|
.get();
|
||||||
assertNoFailures(searchResponse);
|
assertNoFailures(searchResponse);
|
||||||
|
@ -1681,7 +1644,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
// missing nested path
|
// missing nested path
|
||||||
SearchPhaseExecutionException exc = expectThrows(
|
SearchPhaseExecutionException exc = expectThrows(
|
||||||
SearchPhaseExecutionException.class,
|
SearchPhaseExecutionException.class,
|
||||||
() -> client().prepareSearch().setQuery(matchAllQuery()).addSort(SortBuilders.fieldSort("nested.foo")).get()
|
() -> prepareSearch().setQuery(matchAllQuery()).addSort(SortBuilders.fieldSort("nested.foo")).get()
|
||||||
);
|
);
|
||||||
assertThat(exc.toString(), containsString("it is mandatory to set the [nested] context"));
|
assertThat(exc.toString(), containsString("it is mandatory to set the [nested] context"));
|
||||||
}
|
}
|
||||||
|
@ -1766,8 +1729,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
|
|
||||||
{
|
{
|
||||||
Script script = new Script(ScriptType.INLINE, NAME, "doc['number'].value", Collections.emptyMap());
|
Script script = new Script(ScriptType.INLINE, NAME, "doc['number'].value", Collections.emptyMap());
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.setSize(randomIntBetween(1, numDocs + 5))
|
.setSize(randomIntBetween(1, numDocs + 5))
|
||||||
.addSort(SortBuilders.scriptSort(script, ScriptSortBuilder.ScriptSortType.NUMBER))
|
.addSort(SortBuilders.scriptSort(script, ScriptSortBuilder.ScriptSortType.NUMBER))
|
||||||
.addSort(SortBuilders.scoreSort())
|
.addSort(SortBuilders.scoreSort())
|
||||||
|
@ -1783,8 +1745,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
|
|
||||||
{
|
{
|
||||||
Script script = new Script(ScriptType.INLINE, NAME, "doc['keyword'].value", Collections.emptyMap());
|
Script script = new Script(ScriptType.INLINE, NAME, "doc['keyword'].value", Collections.emptyMap());
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.setSize(randomIntBetween(1, numDocs + 5))
|
.setSize(randomIntBetween(1, numDocs + 5))
|
||||||
.addSort(SortBuilders.scriptSort(script, ScriptSortBuilder.ScriptSortType.STRING))
|
.addSort(SortBuilders.scriptSort(script, ScriptSortBuilder.ScriptSortType.STRING))
|
||||||
.addSort(SortBuilders.scoreSort())
|
.addSort(SortBuilders.scoreSort())
|
||||||
|
@ -1812,8 +1773,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
builders.add(client().prepareIndex("new_index").setSource("route_length_miles", 100.2));
|
builders.add(client().prepareIndex("new_index").setSource("route_length_miles", 100.2));
|
||||||
indexRandom(true, true, builders);
|
indexRandom(true, true, builders);
|
||||||
|
|
||||||
SearchResponse response = client().prepareSearch()
|
SearchResponse response = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.setSize(builders.size())
|
.setSize(builders.size())
|
||||||
.addSort(SortBuilders.fieldSort("route_length_miles"))
|
.addSort(SortBuilders.fieldSort("route_length_miles"))
|
||||||
.get();
|
.get();
|
||||||
|
@ -1838,8 +1798,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
builders.add(client().prepareIndex("new_index").setSource("route_length_miles", 100.2));
|
builders.add(client().prepareIndex("new_index").setSource("route_length_miles", 100.2));
|
||||||
indexRandom(true, true, builders);
|
indexRandom(true, true, builders);
|
||||||
|
|
||||||
SearchResponse response = client().prepareSearch()
|
SearchResponse response = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.setSize(builders.size())
|
.setSize(builders.size())
|
||||||
.addSort(SortBuilders.fieldSort("route_length_miles").missing(120.3))
|
.addSort(SortBuilders.fieldSort("route_length_miles").missing(120.3))
|
||||||
.get();
|
.get();
|
||||||
|
@ -1864,8 +1823,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
indexRandom(true, true, builders);
|
indexRandom(true, true, builders);
|
||||||
|
|
||||||
{
|
{
|
||||||
SearchResponse response = client().prepareSearch()
|
SearchResponse response = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.setSize(builders.size())
|
.setSize(builders.size())
|
||||||
.addSort(SortBuilders.fieldSort("field").setNumericType("long"))
|
.addSort(SortBuilders.fieldSort("field").setNumericType("long"))
|
||||||
.get();
|
.get();
|
||||||
|
@ -1881,8 +1839,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
SearchResponse response = client().prepareSearch()
|
SearchResponse response = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.setSize(builders.size())
|
.setSize(builders.size())
|
||||||
.addSort(SortBuilders.fieldSort("field").setNumericType("double"))
|
.addSort(SortBuilders.fieldSort("field").setNumericType("double"))
|
||||||
.get();
|
.get();
|
||||||
|
@ -1908,8 +1865,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
indexRandom(true, true, builders);
|
indexRandom(true, true, builders);
|
||||||
|
|
||||||
{
|
{
|
||||||
SearchResponse response = client().prepareSearch()
|
SearchResponse response = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.setSize(2)
|
.setSize(2)
|
||||||
.addSort(SortBuilders.fieldSort("field").setNumericType("date"))
|
.addSort(SortBuilders.fieldSort("field").setNumericType("date"))
|
||||||
.get();
|
.get();
|
||||||
|
@ -1922,8 +1878,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
assertEquals(1712879236854L, hits.getAt(0).getSortValues()[0]);
|
assertEquals(1712879236854L, hits.getAt(0).getSortValues()[0]);
|
||||||
assertEquals(1712879237000L, hits.getAt(1).getSortValues()[0]);
|
assertEquals(1712879237000L, hits.getAt(1).getSortValues()[0]);
|
||||||
|
|
||||||
response = client().prepareSearch()
|
response = prepareSearch().setMaxConcurrentShardRequests(1)
|
||||||
.setMaxConcurrentShardRequests(1)
|
|
||||||
.setQuery(matchAllQuery())
|
.setQuery(matchAllQuery())
|
||||||
.setSize(1)
|
.setSize(1)
|
||||||
.addSort(SortBuilders.fieldSort("field").setNumericType("date"))
|
.addSort(SortBuilders.fieldSort("field").setNumericType("date"))
|
||||||
|
@ -1934,8 +1889,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
assertThat(hits.getAt(0).getSortValues()[0].getClass(), equalTo(Long.class));
|
assertThat(hits.getAt(0).getSortValues()[0].getClass(), equalTo(Long.class));
|
||||||
assertEquals(1712879236854L, hits.getAt(0).getSortValues()[0]);
|
assertEquals(1712879236854L, hits.getAt(0).getSortValues()[0]);
|
||||||
|
|
||||||
response = client().prepareSearch()
|
response = prepareSearch().setMaxConcurrentShardRequests(1)
|
||||||
.setMaxConcurrentShardRequests(1)
|
|
||||||
.setQuery(matchAllQuery())
|
.setQuery(matchAllQuery())
|
||||||
.setSize(1)
|
.setSize(1)
|
||||||
.addSort(SortBuilders.fieldSort("field").order(SortOrder.DESC).setNumericType("date"))
|
.addSort(SortBuilders.fieldSort("field").order(SortOrder.DESC).setNumericType("date"))
|
||||||
|
@ -1948,8 +1902,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
SearchResponse response = client().prepareSearch()
|
SearchResponse response = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.setSize(2)
|
.setSize(2)
|
||||||
.addSort(SortBuilders.fieldSort("field").setNumericType("date_nanos"))
|
.addSort(SortBuilders.fieldSort("field").setNumericType("date_nanos"))
|
||||||
.get();
|
.get();
|
||||||
|
@ -1961,8 +1914,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
assertEquals(1712879236854775807L, hits.getAt(0).getSortValues()[0]);
|
assertEquals(1712879236854775807L, hits.getAt(0).getSortValues()[0]);
|
||||||
assertEquals(1712879237000000000L, hits.getAt(1).getSortValues()[0]);
|
assertEquals(1712879237000000000L, hits.getAt(1).getSortValues()[0]);
|
||||||
|
|
||||||
response = client().prepareSearch()
|
response = prepareSearch().setMaxConcurrentShardRequests(1)
|
||||||
.setMaxConcurrentShardRequests(1)
|
|
||||||
.setQuery(matchAllQuery())
|
.setQuery(matchAllQuery())
|
||||||
.setSize(1)
|
.setSize(1)
|
||||||
.addSort(SortBuilders.fieldSort("field").setNumericType("date_nanos"))
|
.addSort(SortBuilders.fieldSort("field").setNumericType("date_nanos"))
|
||||||
|
@ -1972,8 +1924,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
assertThat(hits.getAt(0).getSortValues()[0].getClass(), equalTo(Long.class));
|
assertThat(hits.getAt(0).getSortValues()[0].getClass(), equalTo(Long.class));
|
||||||
assertEquals(1712879236854775807L, hits.getAt(0).getSortValues()[0]);
|
assertEquals(1712879236854775807L, hits.getAt(0).getSortValues()[0]);
|
||||||
|
|
||||||
response = client().prepareSearch()
|
response = prepareSearch().setMaxConcurrentShardRequests(1)
|
||||||
.setMaxConcurrentShardRequests(1)
|
|
||||||
.setQuery(matchAllQuery())
|
.setQuery(matchAllQuery())
|
||||||
.setSize(1)
|
.setSize(1)
|
||||||
.addSort(SortBuilders.fieldSort("field").order(SortOrder.DESC).setNumericType("date_nanos"))
|
.addSort(SortBuilders.fieldSort("field").order(SortOrder.DESC).setNumericType("date_nanos"))
|
||||||
|
@ -1988,8 +1939,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
builders.clear();
|
builders.clear();
|
||||||
builders.add(client().prepareIndex("index_date").setSource("field", "1905-04-11T23:47:17"));
|
builders.add(client().prepareIndex("index_date").setSource("field", "1905-04-11T23:47:17"));
|
||||||
indexRandom(true, true, builders);
|
indexRandom(true, true, builders);
|
||||||
SearchResponse response = client().prepareSearch()
|
SearchResponse response = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.setSize(1)
|
.setSize(1)
|
||||||
.addSort(SortBuilders.fieldSort("field").setNumericType("date_nanos"))
|
.addSort(SortBuilders.fieldSort("field").setNumericType("date_nanos"))
|
||||||
.get();
|
.get();
|
||||||
|
@ -2002,8 +1952,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
builders.clear();
|
builders.clear();
|
||||||
builders.add(client().prepareIndex("index_date").setSource("field", "2346-04-11T23:47:17"));
|
builders.add(client().prepareIndex("index_date").setSource("field", "2346-04-11T23:47:17"));
|
||||||
indexRandom(true, true, builders);
|
indexRandom(true, true, builders);
|
||||||
SearchResponse response = client().prepareSearch()
|
SearchResponse response = prepareSearch().setQuery(QueryBuilders.rangeQuery("field").gt("1970-01-01"))
|
||||||
.setQuery(QueryBuilders.rangeQuery("field").gt("1970-01-01"))
|
|
||||||
.setSize(10)
|
.setSize(10)
|
||||||
.addSort(SortBuilders.fieldSort("field").setNumericType("date_nanos"))
|
.addSort(SortBuilders.fieldSort("field").setNumericType("date_nanos"))
|
||||||
.get();
|
.get();
|
||||||
|
@ -2020,8 +1969,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
for (String numericType : new String[] { "long", "double", "date", "date_nanos" }) {
|
for (String numericType : new String[] { "long", "double", "date", "date_nanos" }) {
|
||||||
ElasticsearchException exc = expectThrows(
|
ElasticsearchException exc = expectThrows(
|
||||||
ElasticsearchException.class,
|
ElasticsearchException.class,
|
||||||
() -> client().prepareSearch()
|
() -> prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addSort(SortBuilders.fieldSort(invalidField).setNumericType(numericType))
|
.addSort(SortBuilders.fieldSort(invalidField).setNumericType(numericType))
|
||||||
.get()
|
.get()
|
||||||
);
|
);
|
||||||
|
@ -2050,10 +1998,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
// *** 1. sort DESC on long_field
|
// *** 1. sort DESC on long_field
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().addSort(new FieldSortBuilder("long_field").order(SortOrder.DESC)).setSize(10).get();
|
||||||
.addSort(new FieldSortBuilder("long_field").order(SortOrder.DESC))
|
|
||||||
.setSize(10)
|
|
||||||
.get();
|
|
||||||
assertNoFailures(searchResponse);
|
assertNoFailures(searchResponse);
|
||||||
long previousLong = Long.MAX_VALUE;
|
long previousLong = Long.MAX_VALUE;
|
||||||
for (int i = 0; i < searchResponse.getHits().getHits().length; i++) {
|
for (int i = 0; i < searchResponse.getHits().getHits().length; i++) {
|
||||||
|
@ -2065,7 +2010,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
// *** 2. sort ASC on long_field
|
// *** 2. sort ASC on long_field
|
||||||
searchResponse = client().prepareSearch().addSort(new FieldSortBuilder("long_field").order(SortOrder.ASC)).setSize(10).get();
|
searchResponse = prepareSearch().addSort(new FieldSortBuilder("long_field").order(SortOrder.ASC)).setSize(10).get();
|
||||||
assertNoFailures(searchResponse);
|
assertNoFailures(searchResponse);
|
||||||
previousLong = Long.MIN_VALUE;
|
previousLong = Long.MIN_VALUE;
|
||||||
for (int i = 0; i < searchResponse.getHits().getHits().length; i++) {
|
for (int i = 0; i < searchResponse.getHits().getHits().length; i++) {
|
||||||
|
@ -2090,8 +2035,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
{ // mixing long and integer types is ok, as we convert integer sort to long sort
|
{ // mixing long and integer types is ok, as we convert integer sort to long sort
|
||||||
SearchResponse searchResponse = client().prepareSearch("index_long", "index_integer")
|
SearchResponse searchResponse = prepareSearch("index_long", "index_integer").addSort(new FieldSortBuilder("foo"))
|
||||||
.addSort(new FieldSortBuilder("foo"))
|
|
||||||
.setSize(10)
|
.setSize(10)
|
||||||
.get();
|
.get();
|
||||||
assertNoFailures(searchResponse);
|
assertNoFailures(searchResponse);
|
||||||
|
@ -2102,7 +2046,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
{ // mixing long and double types is not allowed
|
{ // mixing long and double types is not allowed
|
||||||
SearchPhaseExecutionException exc = expectThrows(
|
SearchPhaseExecutionException exc = expectThrows(
|
||||||
SearchPhaseExecutionException.class,
|
SearchPhaseExecutionException.class,
|
||||||
() -> client().prepareSearch("index_long", "index_double").addSort(new FieldSortBuilder("foo")).setSize(10).get()
|
() -> prepareSearch("index_long", "index_double").addSort(new FieldSortBuilder("foo")).setSize(10).get()
|
||||||
);
|
);
|
||||||
assertThat(exc.getCause().toString(), containsString(errMsg));
|
assertThat(exc.getCause().toString(), containsString(errMsg));
|
||||||
}
|
}
|
||||||
|
@ -2110,7 +2054,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
{ // mixing long and keyword types is not allowed
|
{ // mixing long and keyword types is not allowed
|
||||||
SearchPhaseExecutionException exc = expectThrows(
|
SearchPhaseExecutionException exc = expectThrows(
|
||||||
SearchPhaseExecutionException.class,
|
SearchPhaseExecutionException.class,
|
||||||
() -> client().prepareSearch("index_long", "index_keyword").addSort(new FieldSortBuilder("foo")).setSize(10).get()
|
() -> prepareSearch("index_long", "index_keyword").addSort(new FieldSortBuilder("foo")).setSize(10).get()
|
||||||
);
|
);
|
||||||
assertThat(exc.getCause().toString(), containsString(errMsg));
|
assertThat(exc.getCause().toString(), containsString(errMsg));
|
||||||
}
|
}
|
||||||
|
|
|
@ -614,8 +614,7 @@ public class GeoDistanceIT extends ESIntegTestCase {
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
// Order: Asc
|
// Order: Asc
|
||||||
SearchResponse searchResponse = client().prepareSearch("test1", "test2")
|
SearchResponse searchResponse = prepareSearch("test1", "test2").setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addSort(SortBuilders.geoDistanceSort("locations", 40.7143528, -74.0059731).ignoreUnmapped(true).order(SortOrder.ASC))
|
.addSort(SortBuilders.geoDistanceSort("locations", 40.7143528, -74.0059731).ignoreUnmapped(true).order(SortOrder.ASC))
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
|
@ -625,8 +624,7 @@ public class GeoDistanceIT extends ESIntegTestCase {
|
||||||
assertThat(((Number) searchResponse.getHits().getAt(1).getSortValues()[0]).doubleValue(), equalTo(Double.POSITIVE_INFINITY));
|
assertThat(((Number) searchResponse.getHits().getAt(1).getSortValues()[0]).doubleValue(), equalTo(Double.POSITIVE_INFINITY));
|
||||||
|
|
||||||
// Order: Desc
|
// Order: Desc
|
||||||
searchResponse = client().prepareSearch("test1", "test2")
|
searchResponse = prepareSearch("test1", "test2").setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addSort(SortBuilders.geoDistanceSort("locations", 40.7143528, -74.0059731).ignoreUnmapped(true).order(SortOrder.DESC))
|
.addSort(SortBuilders.geoDistanceSort("locations", 40.7143528, -74.0059731).ignoreUnmapped(true).order(SortOrder.DESC))
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
|
@ -637,8 +635,7 @@ public class GeoDistanceIT extends ESIntegTestCase {
|
||||||
assertThat(((Number) searchResponse.getHits().getAt(1).getSortValues()[0]).doubleValue(), closeTo(5286d, 10d));
|
assertThat(((Number) searchResponse.getHits().getAt(1).getSortValues()[0]).doubleValue(), closeTo(5286d, 10d));
|
||||||
|
|
||||||
// Make sure that by default the unmapped fields continue to fail
|
// Make sure that by default the unmapped fields continue to fail
|
||||||
searchResponse = client().prepareSearch("test1", "test2")
|
searchResponse = prepareSearch("test1", "test2").setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addSort(SortBuilders.geoDistanceSort("locations", 40.7143528, -74.0059731).order(SortOrder.DESC))
|
.addSort(SortBuilders.geoDistanceSort("locations", 40.7143528, -74.0059731).order(SortOrder.DESC))
|
||||||
.get();
|
.get();
|
||||||
assertThat(searchResponse.getFailedShards(), greaterThan(0));
|
assertThat(searchResponse.getFailedShards(), greaterThan(0));
|
||||||
|
|
|
@ -84,8 +84,7 @@ public class GeoDistanceSortBuilderIT extends ESIntegTestCase {
|
||||||
q[0] = new GeoPoint(2, 1);
|
q[0] = new GeoPoint(2, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addSort(new GeoDistanceSortBuilder(LOCATION_FIELD, q).sortMode(SortMode.MIN).order(SortOrder.ASC))
|
.addSort(new GeoDistanceSortBuilder(LOCATION_FIELD, q).sortMode(SortMode.MIN).order(SortOrder.ASC))
|
||||||
.get();
|
.get();
|
||||||
assertOrderedSearchHits(searchResponse, "d1", "d2");
|
assertOrderedSearchHits(searchResponse, "d1", "d2");
|
||||||
|
@ -98,8 +97,7 @@ public class GeoDistanceSortBuilderIT extends ESIntegTestCase {
|
||||||
closeTo(GeoDistance.ARC.calculate(2, 1, 5, 1, DistanceUnit.METERS), 10d)
|
closeTo(GeoDistance.ARC.calculate(2, 1, 5, 1, DistanceUnit.METERS), 10d)
|
||||||
);
|
);
|
||||||
|
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addSort(new GeoDistanceSortBuilder(LOCATION_FIELD, q).sortMode(SortMode.MIN).order(SortOrder.DESC))
|
.addSort(new GeoDistanceSortBuilder(LOCATION_FIELD, q).sortMode(SortMode.MIN).order(SortOrder.DESC))
|
||||||
.get();
|
.get();
|
||||||
assertOrderedSearchHits(searchResponse, "d2", "d1");
|
assertOrderedSearchHits(searchResponse, "d2", "d1");
|
||||||
|
@ -112,8 +110,7 @@ public class GeoDistanceSortBuilderIT extends ESIntegTestCase {
|
||||||
closeTo(GeoDistance.ARC.calculate(2, 2, 3, 2, DistanceUnit.METERS), 10d)
|
closeTo(GeoDistance.ARC.calculate(2, 2, 3, 2, DistanceUnit.METERS), 10d)
|
||||||
);
|
);
|
||||||
|
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addSort(new GeoDistanceSortBuilder(LOCATION_FIELD, q).sortMode(SortMode.MAX).order(SortOrder.ASC))
|
.addSort(new GeoDistanceSortBuilder(LOCATION_FIELD, q).sortMode(SortMode.MAX).order(SortOrder.ASC))
|
||||||
.get();
|
.get();
|
||||||
assertOrderedSearchHits(searchResponse, "d1", "d2");
|
assertOrderedSearchHits(searchResponse, "d1", "d2");
|
||||||
|
@ -126,8 +123,7 @@ public class GeoDistanceSortBuilderIT extends ESIntegTestCase {
|
||||||
closeTo(GeoDistance.ARC.calculate(2, 1, 6, 2, DistanceUnit.METERS), 10d)
|
closeTo(GeoDistance.ARC.calculate(2, 1, 6, 2, DistanceUnit.METERS), 10d)
|
||||||
);
|
);
|
||||||
|
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addSort(new GeoDistanceSortBuilder(LOCATION_FIELD, q).sortMode(SortMode.MAX).order(SortOrder.DESC))
|
.addSort(new GeoDistanceSortBuilder(LOCATION_FIELD, q).sortMode(SortMode.MAX).order(SortOrder.DESC))
|
||||||
.get();
|
.get();
|
||||||
assertOrderedSearchHits(searchResponse, "d2", "d1");
|
assertOrderedSearchHits(searchResponse, "d2", "d1");
|
||||||
|
@ -168,8 +164,7 @@ public class GeoDistanceSortBuilderIT extends ESIntegTestCase {
|
||||||
);
|
);
|
||||||
GeoPoint q = new GeoPoint(0, 0);
|
GeoPoint q = new GeoPoint(0, 0);
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addSort(new GeoDistanceSortBuilder(LOCATION_FIELD, q).sortMode(SortMode.AVG).order(SortOrder.ASC))
|
.addSort(new GeoDistanceSortBuilder(LOCATION_FIELD, q).sortMode(SortMode.AVG).order(SortOrder.ASC))
|
||||||
.get();
|
.get();
|
||||||
assertOrderedSearchHits(searchResponse, "d2", "d1");
|
assertOrderedSearchHits(searchResponse, "d2", "d1");
|
||||||
|
@ -182,8 +177,7 @@ public class GeoDistanceSortBuilderIT extends ESIntegTestCase {
|
||||||
closeTo(GeoDistance.ARC.calculate(0, 0, 0, 5, DistanceUnit.METERS), 10d)
|
closeTo(GeoDistance.ARC.calculate(0, 0, 0, 5, DistanceUnit.METERS), 10d)
|
||||||
);
|
);
|
||||||
|
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addSort(new GeoDistanceSortBuilder(LOCATION_FIELD, q).sortMode(SortMode.MEDIAN).order(SortOrder.ASC))
|
.addSort(new GeoDistanceSortBuilder(LOCATION_FIELD, q).sortMode(SortMode.MEDIAN).order(SortOrder.ASC))
|
||||||
.get();
|
.get();
|
||||||
assertOrderedSearchHits(searchResponse, "d1", "d2");
|
assertOrderedSearchHits(searchResponse, "d1", "d2");
|
||||||
|
@ -251,8 +245,7 @@ public class GeoDistanceSortBuilderIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addSort(geoDistanceSortBuilder.sortMode(SortMode.MIN).order(SortOrder.ASC))
|
.addSort(geoDistanceSortBuilder.sortMode(SortMode.MIN).order(SortOrder.ASC))
|
||||||
.get();
|
.get();
|
||||||
assertOrderedSearchHits(searchResponse, "d1", "d2");
|
assertOrderedSearchHits(searchResponse, "d1", "d2");
|
||||||
|
@ -265,8 +258,7 @@ public class GeoDistanceSortBuilderIT extends ESIntegTestCase {
|
||||||
closeTo(GeoDistance.ARC.calculate(4.5, 1, 2, 1, DistanceUnit.METERS), 1.e-1)
|
closeTo(GeoDistance.ARC.calculate(4.5, 1, 2, 1, DistanceUnit.METERS), 1.e-1)
|
||||||
);
|
);
|
||||||
|
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addSort(geoDistanceSortBuilder.sortMode(SortMode.MAX).order(SortOrder.ASC))
|
.addSort(geoDistanceSortBuilder.sortMode(SortMode.MAX).order(SortOrder.ASC))
|
||||||
.get();
|
.get();
|
||||||
assertOrderedSearchHits(searchResponse, "d1", "d2");
|
assertOrderedSearchHits(searchResponse, "d1", "d2");
|
||||||
|
@ -297,50 +289,41 @@ public class GeoDistanceSortBuilderIT extends ESIntegTestCase {
|
||||||
|
|
||||||
GeoDistanceSortBuilder geoDistanceSortBuilder = new GeoDistanceSortBuilder(LOCATION_FIELD, hashPoint);
|
GeoDistanceSortBuilder geoDistanceSortBuilder = new GeoDistanceSortBuilder(LOCATION_FIELD, hashPoint);
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addSort(geoDistanceSortBuilder.sortMode(SortMode.MIN).order(SortOrder.ASC))
|
.addSort(geoDistanceSortBuilder.sortMode(SortMode.MIN).order(SortOrder.ASC))
|
||||||
.get();
|
.get();
|
||||||
checkCorrectSortOrderForGeoSort(searchResponse);
|
checkCorrectSortOrderForGeoSort(searchResponse);
|
||||||
|
|
||||||
geoDistanceSortBuilder = new GeoDistanceSortBuilder(LOCATION_FIELD, new GeoPoint(2, 2));
|
geoDistanceSortBuilder = new GeoDistanceSortBuilder(LOCATION_FIELD, new GeoPoint(2, 2));
|
||||||
|
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addSort(geoDistanceSortBuilder.sortMode(SortMode.MIN).order(SortOrder.ASC))
|
.addSort(geoDistanceSortBuilder.sortMode(SortMode.MIN).order(SortOrder.ASC))
|
||||||
.get();
|
.get();
|
||||||
checkCorrectSortOrderForGeoSort(searchResponse);
|
checkCorrectSortOrderForGeoSort(searchResponse);
|
||||||
|
|
||||||
geoDistanceSortBuilder = new GeoDistanceSortBuilder(LOCATION_FIELD, 2, 2);
|
geoDistanceSortBuilder = new GeoDistanceSortBuilder(LOCATION_FIELD, 2, 2);
|
||||||
|
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addSort(geoDistanceSortBuilder.sortMode(SortMode.MIN).order(SortOrder.ASC))
|
.addSort(geoDistanceSortBuilder.sortMode(SortMode.MIN).order(SortOrder.ASC))
|
||||||
.get();
|
.get();
|
||||||
checkCorrectSortOrderForGeoSort(searchResponse);
|
checkCorrectSortOrderForGeoSort(searchResponse);
|
||||||
|
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setSource(new SearchSourceBuilder().sort(SortBuilders.geoDistanceSort(LOCATION_FIELD, 2.0, 2.0)))
|
||||||
.setSource(new SearchSourceBuilder().sort(SortBuilders.geoDistanceSort(LOCATION_FIELD, 2.0, 2.0)))
|
|
||||||
.get();
|
.get();
|
||||||
checkCorrectSortOrderForGeoSort(searchResponse);
|
checkCorrectSortOrderForGeoSort(searchResponse);
|
||||||
|
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setSource(
|
||||||
.setSource(new SearchSourceBuilder().sort(SortBuilders.geoDistanceSort(LOCATION_FIELD, "s037ms06g7h0")))
|
new SearchSourceBuilder().sort(SortBuilders.geoDistanceSort(LOCATION_FIELD, "s037ms06g7h0"))
|
||||||
|
).get();
|
||||||
|
checkCorrectSortOrderForGeoSort(searchResponse);
|
||||||
|
|
||||||
|
searchResponse = prepareSearch().setSource(new SearchSourceBuilder().sort(SortBuilders.geoDistanceSort(LOCATION_FIELD, 2.0, 2.0)))
|
||||||
.get();
|
.get();
|
||||||
checkCorrectSortOrderForGeoSort(searchResponse);
|
checkCorrectSortOrderForGeoSort(searchResponse);
|
||||||
|
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setSource(
|
||||||
.setSource(new SearchSourceBuilder().sort(SortBuilders.geoDistanceSort(LOCATION_FIELD, 2.0, 2.0)))
|
new SearchSourceBuilder().sort(SortBuilders.geoDistanceSort(LOCATION_FIELD, 2.0, 2.0).validation(GeoValidationMethod.COERCE))
|
||||||
.get();
|
).get();
|
||||||
checkCorrectSortOrderForGeoSort(searchResponse);
|
|
||||||
|
|
||||||
searchResponse = client().prepareSearch()
|
|
||||||
.setSource(
|
|
||||||
new SearchSourceBuilder().sort(
|
|
||||||
SortBuilders.geoDistanceSort(LOCATION_FIELD, 2.0, 2.0).validation(GeoValidationMethod.COERCE)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.get();
|
|
||||||
checkCorrectSortOrderForGeoSort(searchResponse);
|
checkCorrectSortOrderForGeoSort(searchResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -369,24 +352,21 @@ public class GeoDistanceSortBuilderIT extends ESIntegTestCase {
|
||||||
);
|
);
|
||||||
|
|
||||||
assertSortValues(
|
assertSortValues(
|
||||||
client().prepareSearch("test1", "test2")
|
prepareSearch("test1", "test2").addSort(fieldSort("str_field").order(SortOrder.ASC).unmappedType("keyword"))
|
||||||
.addSort(fieldSort("str_field").order(SortOrder.ASC).unmappedType("keyword"))
|
|
||||||
.addSort(fieldSort("str_field2").order(SortOrder.DESC).unmappedType("keyword")),
|
.addSort(fieldSort("str_field2").order(SortOrder.DESC).unmappedType("keyword")),
|
||||||
new Object[] { "bcd", null },
|
new Object[] { "bcd", null },
|
||||||
new Object[] { null, null }
|
new Object[] { null, null }
|
||||||
);
|
);
|
||||||
|
|
||||||
assertSortValues(
|
assertSortValues(
|
||||||
client().prepareSearch("test1", "test2")
|
prepareSearch("test1", "test2").addSort(fieldSort("long_field").order(SortOrder.ASC).unmappedType("long"))
|
||||||
.addSort(fieldSort("long_field").order(SortOrder.ASC).unmappedType("long"))
|
|
||||||
.addSort(fieldSort("long_field2").order(SortOrder.DESC).unmappedType("long")),
|
.addSort(fieldSort("long_field2").order(SortOrder.DESC).unmappedType("long")),
|
||||||
new Object[] { 3L, Long.MIN_VALUE },
|
new Object[] { 3L, Long.MIN_VALUE },
|
||||||
new Object[] { Long.MAX_VALUE, Long.MIN_VALUE }
|
new Object[] { Long.MAX_VALUE, Long.MIN_VALUE }
|
||||||
);
|
);
|
||||||
|
|
||||||
assertSortValues(
|
assertSortValues(
|
||||||
client().prepareSearch("test1", "test2")
|
prepareSearch("test1", "test2").addSort(fieldSort("double_field").order(SortOrder.ASC).unmappedType("double"))
|
||||||
.addSort(fieldSort("double_field").order(SortOrder.ASC).unmappedType("double"))
|
|
||||||
.addSort(fieldSort("double_field2").order(SortOrder.DESC).unmappedType("double")),
|
.addSort(fieldSort("double_field2").order(SortOrder.DESC).unmappedType("double")),
|
||||||
new Object[] { 0.65, Double.NEGATIVE_INFINITY },
|
new Object[] { 0.65, Double.NEGATIVE_INFINITY },
|
||||||
new Object[] { Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY }
|
new Object[] { Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY }
|
||||||
|
|
|
@ -181,8 +181,7 @@ public class SimpleSortIT extends ESIntegTestCase {
|
||||||
|
|
||||||
Script script = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc['str_value'].value", Collections.emptyMap());
|
Script script = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc['str_value'].value", Collections.emptyMap());
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.setSize(size)
|
.setSize(size)
|
||||||
.addSort(new ScriptSortBuilder(script, ScriptSortType.STRING))
|
.addSort(new ScriptSortBuilder(script, ScriptSortType.STRING))
|
||||||
.get();
|
.get();
|
||||||
|
@ -198,7 +197,7 @@ public class SimpleSortIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
size = 1 + random.nextInt(10);
|
size = 1 + random.nextInt(10);
|
||||||
searchResponse = client().prepareSearch().setQuery(matchAllQuery()).setSize(size).addSort("str_value", SortOrder.DESC).get();
|
searchResponse = prepareSearch().setQuery(matchAllQuery()).setSize(size).addSort("str_value", SortOrder.DESC).get();
|
||||||
|
|
||||||
assertHitCount(searchResponse, 10);
|
assertHitCount(searchResponse, 10);
|
||||||
assertThat(searchResponse.getHits().getHits().length, equalTo(size));
|
assertThat(searchResponse.getHits().getHits().length, equalTo(size));
|
||||||
|
@ -261,8 +260,7 @@ public class SimpleSortIT extends ESIntegTestCase {
|
||||||
indicesAdmin().prepareRefresh("test").get();
|
indicesAdmin().prepareRefresh("test").get();
|
||||||
|
|
||||||
// test the long values
|
// test the long values
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addScriptField("min", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "get min long", Collections.emptyMap()))
|
.addScriptField("min", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "get min long", Collections.emptyMap()))
|
||||||
.addSort(SortBuilders.fieldSort("ord").order(SortOrder.ASC).unmappedType("long"))
|
.addSort(SortBuilders.fieldSort("ord").order(SortOrder.ASC).unmappedType("long"))
|
||||||
.setSize(10)
|
.setSize(10)
|
||||||
|
@ -277,8 +275,7 @@ public class SimpleSortIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test the double values
|
// test the double values
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addScriptField("min", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "get min double", Collections.emptyMap()))
|
.addScriptField("min", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "get min double", Collections.emptyMap()))
|
||||||
.addSort(SortBuilders.fieldSort("ord").order(SortOrder.ASC).unmappedType("long"))
|
.addSort(SortBuilders.fieldSort("ord").order(SortOrder.ASC).unmappedType("long"))
|
||||||
.setSize(10)
|
.setSize(10)
|
||||||
|
@ -293,8 +290,7 @@ public class SimpleSortIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test the string values
|
// test the string values
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addScriptField("min", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "get min string", Collections.emptyMap()))
|
.addScriptField("min", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "get min string", Collections.emptyMap()))
|
||||||
.addSort(SortBuilders.fieldSort("ord").order(SortOrder.ASC).unmappedType("long"))
|
.addSort(SortBuilders.fieldSort("ord").order(SortOrder.ASC).unmappedType("long"))
|
||||||
.setSize(10)
|
.setSize(10)
|
||||||
|
@ -309,8 +305,7 @@ public class SimpleSortIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test the geopoint values
|
// test the geopoint values
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addScriptField("min", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "get min geopoint lon", Collections.emptyMap()))
|
.addScriptField("min", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "get min geopoint lon", Collections.emptyMap()))
|
||||||
.addSort(SortBuilders.fieldSort("ord").order(SortOrder.ASC).unmappedType("long"))
|
.addSort(SortBuilders.fieldSort("ord").order(SortOrder.ASC).unmappedType("long"))
|
||||||
.setSize(10)
|
.setSize(10)
|
||||||
|
@ -355,8 +350,7 @@ public class SimpleSortIT extends ESIntegTestCase {
|
||||||
|
|
||||||
Script scripField = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc['id'].value", Collections.emptyMap());
|
Script scripField = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc['id'].value", Collections.emptyMap());
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addScriptField("id", scripField)
|
.addScriptField("id", scripField)
|
||||||
.addSort("svalue", SortOrder.ASC)
|
.addSort("svalue", SortOrder.ASC)
|
||||||
.get();
|
.get();
|
||||||
|
@ -368,8 +362,7 @@ public class SimpleSortIT extends ESIntegTestCase {
|
||||||
assertThat(searchResponse.getHits().getAt(1).field("id").getValue(), equalTo("3"));
|
assertThat(searchResponse.getHits().getAt(1).field("id").getValue(), equalTo("3"));
|
||||||
assertThat(searchResponse.getHits().getAt(2).field("id").getValue(), equalTo("2"));
|
assertThat(searchResponse.getHits().getAt(2).field("id").getValue(), equalTo("2"));
|
||||||
|
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addScriptField("id", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc['id'][0]", Collections.emptyMap()))
|
.addScriptField("id", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc['id'][0]", Collections.emptyMap()))
|
||||||
.addSort("svalue", SortOrder.ASC)
|
.addSort("svalue", SortOrder.ASC)
|
||||||
.get();
|
.get();
|
||||||
|
@ -381,11 +374,7 @@ public class SimpleSortIT extends ESIntegTestCase {
|
||||||
assertThat(searchResponse.getHits().getAt(1).field("id").getValue(), equalTo("3"));
|
assertThat(searchResponse.getHits().getAt(1).field("id").getValue(), equalTo("3"));
|
||||||
assertThat(searchResponse.getHits().getAt(2).field("id").getValue(), equalTo("2"));
|
assertThat(searchResponse.getHits().getAt(2).field("id").getValue(), equalTo("2"));
|
||||||
|
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(matchAllQuery()).addScriptField("id", scripField).addSort("svalue", SortOrder.DESC).get();
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addScriptField("id", scripField)
|
|
||||||
.addSort("svalue", SortOrder.DESC)
|
|
||||||
.get();
|
|
||||||
|
|
||||||
if (searchResponse.getFailedShards() > 0) {
|
if (searchResponse.getFailedShards() > 0) {
|
||||||
logger.warn("Failed shards:");
|
logger.warn("Failed shards:");
|
||||||
|
@ -401,8 +390,7 @@ public class SimpleSortIT extends ESIntegTestCase {
|
||||||
assertThat(searchResponse.getHits().getAt(2).field("id").getValue(), equalTo("2"));
|
assertThat(searchResponse.getHits().getAt(2).field("id").getValue(), equalTo("2"));
|
||||||
|
|
||||||
// a query with docs just with null values
|
// a query with docs just with null values
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(termQuery("id", "2"))
|
||||||
.setQuery(termQuery("id", "2"))
|
|
||||||
.addScriptField("id", scripField)
|
.addScriptField("id", scripField)
|
||||||
.addSort("svalue", SortOrder.DESC)
|
.addSort("svalue", SortOrder.DESC)
|
||||||
.get();
|
.get();
|
||||||
|
@ -443,8 +431,6 @@ public class SimpleSortIT extends ESIntegTestCase {
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
Script sortScript = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "\u0027\u0027", Collections.emptyMap());
|
Script sortScript = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "\u0027\u0027", Collections.emptyMap());
|
||||||
assertNoFailures(
|
assertNoFailures(prepareSearch().setQuery(matchAllQuery()).addSort(scriptSort(sortScript, ScriptSortType.STRING)).setSize(10));
|
||||||
client().prepareSearch().setQuery(matchAllQuery()).addSort(scriptSort(sortScript, ScriptSortType.STRING)).setSize(10)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,8 +73,7 @@ public class FieldUsageStatsIT extends ESIntegTestCase {
|
||||||
assertFalse(stats.hasField("field2"));
|
assertFalse(stats.hasField("field2"));
|
||||||
assertFalse(stats.hasField("date_field"));
|
assertFalse(stats.hasField("date_field"));
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setSearchType(SearchType.DEFAULT)
|
||||||
.setSearchType(SearchType.DEFAULT)
|
|
||||||
.setQuery(QueryBuilders.termQuery("field", "value"))
|
.setQuery(QueryBuilders.termQuery("field", "value"))
|
||||||
.addAggregation(AggregationBuilders.terms("agg1").field("field.keyword"))
|
.addAggregation(AggregationBuilders.terms("agg1").field("field.keyword"))
|
||||||
.addAggregation(AggregationBuilders.filter("agg2", QueryBuilders.spanTermQuery("field2", "value2")))
|
.addAggregation(AggregationBuilders.filter("agg2", QueryBuilders.spanTermQuery("field2", "value2")))
|
||||||
|
@ -114,8 +113,7 @@ public class FieldUsageStatsIT extends ESIntegTestCase {
|
||||||
assertEquals(Set.of(UsageContext.DOC_VALUES), stats.get("field.keyword").keySet());
|
assertEquals(Set.of(UsageContext.DOC_VALUES), stats.get("field.keyword").keySet());
|
||||||
assertEquals(1L * numShards, stats.get("field.keyword").getDocValues());
|
assertEquals(1L * numShards, stats.get("field.keyword").getDocValues());
|
||||||
|
|
||||||
client().prepareSearch()
|
prepareSearch().setSearchType(SearchType.DEFAULT)
|
||||||
.setSearchType(SearchType.DEFAULT)
|
|
||||||
.setQuery(QueryBuilders.termQuery("field", "value"))
|
.setQuery(QueryBuilders.termQuery("field", "value"))
|
||||||
.addAggregation(AggregationBuilders.terms("agg1").field("field.keyword"))
|
.addAggregation(AggregationBuilders.terms("agg1").field("field.keyword"))
|
||||||
.setSize(0)
|
.setSize(0)
|
||||||
|
@ -144,8 +142,7 @@ public class FieldUsageStatsIT extends ESIntegTestCase {
|
||||||
.getTotal()
|
.getTotal()
|
||||||
.getQueryCount()
|
.getQueryCount()
|
||||||
);
|
);
|
||||||
client().prepareSearch()
|
prepareSearch().setSearchType(SearchType.DEFAULT)
|
||||||
.setSearchType(SearchType.DEFAULT)
|
|
||||||
.setPreFilterShardSize(1)
|
.setPreFilterShardSize(1)
|
||||||
.setQuery(QueryBuilders.rangeQuery("date_field").from("2016/01/01"))
|
.setQuery(QueryBuilders.rangeQuery("date_field").from("2016/01/01"))
|
||||||
.setSize(100)
|
.setSize(100)
|
||||||
|
|
|
@ -188,8 +188,7 @@ public class SearchStatsIT extends ESIntegTestCase {
|
||||||
assertThat(indicesStats.getTotal().getSearch().getOpenContexts(), equalTo(0L));
|
assertThat(indicesStats.getTotal().getSearch().getOpenContexts(), equalTo(0L));
|
||||||
|
|
||||||
int size = scaledRandomIntBetween(1, docs);
|
int size = scaledRandomIntBetween(1, docs);
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.setSize(size)
|
.setSize(size)
|
||||||
.setScroll(TimeValue.timeValueMinutes(2))
|
.setScroll(TimeValue.timeValueMinutes(2))
|
||||||
.get();
|
.get();
|
||||||
|
|
|
@ -245,7 +245,7 @@ public class SuggestSearchIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
SearchResponse search = client().prepareSearch().setQuery(matchQuery("text", "spellchecker")).get();
|
SearchResponse search = prepareSearch().setQuery(matchQuery("text", "spellchecker")).get();
|
||||||
assertThat("didn't ask for suggestions but got some", search.getSuggest(), nullValue());
|
assertThat("didn't ask for suggestions but got some", search.getSuggest(), nullValue());
|
||||||
|
|
||||||
TermSuggestionBuilder termSuggestion = termSuggestion("text").suggestMode(SuggestMode.ALWAYS) // Always, otherwise the results can
|
TermSuggestionBuilder termSuggestion = termSuggestion("text").suggestMode(SuggestMode.ALWAYS) // Always, otherwise the results can
|
||||||
|
@ -308,12 +308,12 @@ public class SuggestSearchIT extends ESIntegTestCase {
|
||||||
candidateGenerator("name").prefixLength(0).minWordLength(0).suggestMode("always").maxEdits(2)
|
candidateGenerator("name").prefixLength(0).minWordLength(0).suggestMode("always").maxEdits(2)
|
||||||
).gramSize(3);
|
).gramSize(3);
|
||||||
{
|
{
|
||||||
SearchRequestBuilder searchBuilder = client().prepareSearch().setSize(0);
|
SearchRequestBuilder searchBuilder = prepareSearch().setSize(0);
|
||||||
searchBuilder.suggest(new SuggestBuilder().setGlobalText("tetsting sugestion").addSuggestion("did_you_mean", phraseSuggestion));
|
searchBuilder.suggest(new SuggestBuilder().setGlobalText("tetsting sugestion").addSuggestion("did_you_mean", phraseSuggestion));
|
||||||
assertRequestBuilderThrows(searchBuilder, SearchPhaseExecutionException.class);
|
assertRequestBuilderThrows(searchBuilder, SearchPhaseExecutionException.class);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
SearchRequestBuilder searchBuilder = client().prepareSearch().setSize(0);
|
SearchRequestBuilder searchBuilder = prepareSearch().setSize(0);
|
||||||
searchBuilder.suggest(new SuggestBuilder().setGlobalText("tetsting sugestion").addSuggestion("did_you_mean", phraseSuggestion));
|
searchBuilder.suggest(new SuggestBuilder().setGlobalText("tetsting sugestion").addSuggestion("did_you_mean", phraseSuggestion));
|
||||||
assertRequestBuilderThrows(searchBuilder, SearchPhaseExecutionException.class);
|
assertRequestBuilderThrows(searchBuilder, SearchPhaseExecutionException.class);
|
||||||
}
|
}
|
||||||
|
@ -329,7 +329,7 @@ public class SuggestSearchIT extends ESIntegTestCase {
|
||||||
indexDoc("test", "4", "text", "abcc");
|
indexDoc("test", "4", "text", "abcc");
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
SearchResponse search = client().prepareSearch().setQuery(matchQuery("text", "spellcecker")).get();
|
SearchResponse search = prepareSearch().setQuery(matchQuery("text", "spellcecker")).get();
|
||||||
assertThat("didn't ask for suggestions but got some", search.getSuggest(), nullValue());
|
assertThat("didn't ask for suggestions but got some", search.getSuggest(), nullValue());
|
||||||
|
|
||||||
TermSuggestionBuilder termSuggest = termSuggestion("text").suggestMode(SuggestMode.ALWAYS) // Always, otherwise the results can vary
|
TermSuggestionBuilder termSuggest = termSuggestion("text").suggestMode(SuggestMode.ALWAYS) // Always, otherwise the results can vary
|
||||||
|
@ -828,8 +828,7 @@ public class SuggestSearchIT extends ESIntegTestCase {
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
// When searching on a shard with a non existing mapping, we should fail
|
// When searching on a shard with a non existing mapping, we should fail
|
||||||
SearchRequestBuilder request = client().prepareSearch()
|
SearchRequestBuilder request = prepareSearch().setSize(0)
|
||||||
.setSize(0)
|
|
||||||
.suggest(
|
.suggest(
|
||||||
new SuggestBuilder().setGlobalText("tetsting sugestion")
|
new SuggestBuilder().setGlobalText("tetsting sugestion")
|
||||||
.addSuggestion("did_you_mean", phraseSuggestion("fielddoesnotexist").maxErrors(5.0f))
|
.addSuggestion("did_you_mean", phraseSuggestion("fielddoesnotexist").maxErrors(5.0f))
|
||||||
|
@ -837,8 +836,7 @@ public class SuggestSearchIT extends ESIntegTestCase {
|
||||||
assertRequestBuilderThrows(request, SearchPhaseExecutionException.class);
|
assertRequestBuilderThrows(request, SearchPhaseExecutionException.class);
|
||||||
|
|
||||||
// When searching on a shard which does not hold yet any document of an existing type, we should not fail
|
// When searching on a shard which does not hold yet any document of an existing type, we should not fail
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setSize(0)
|
||||||
.setSize(0)
|
|
||||||
.suggest(
|
.suggest(
|
||||||
new SuggestBuilder().setGlobalText("tetsting sugestion")
|
new SuggestBuilder().setGlobalText("tetsting sugestion")
|
||||||
.addSuggestion("did_you_mean", phraseSuggestion("name").maxErrors(5.0f))
|
.addSuggestion("did_you_mean", phraseSuggestion("name").maxErrors(5.0f))
|
||||||
|
@ -878,8 +876,7 @@ public class SuggestSearchIT extends ESIntegTestCase {
|
||||||
ensureGreen();
|
ensureGreen();
|
||||||
|
|
||||||
// test phrase suggestion on completely empty index
|
// test phrase suggestion on completely empty index
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setSize(0)
|
||||||
.setSize(0)
|
|
||||||
.suggest(
|
.suggest(
|
||||||
new SuggestBuilder().setGlobalText("tetsting sugestion")
|
new SuggestBuilder().setGlobalText("tetsting sugestion")
|
||||||
.addSuggestion("did_you_mean", phraseSuggestion("name").maxErrors(5.0f))
|
.addSuggestion("did_you_mean", phraseSuggestion("name").maxErrors(5.0f))
|
||||||
|
@ -897,8 +894,7 @@ public class SuggestSearchIT extends ESIntegTestCase {
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
// test phrase suggestion but nothing matches
|
// test phrase suggestion but nothing matches
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setSize(0)
|
||||||
.setSize(0)
|
|
||||||
.suggest(
|
.suggest(
|
||||||
new SuggestBuilder().setGlobalText("tetsting sugestion")
|
new SuggestBuilder().setGlobalText("tetsting sugestion")
|
||||||
.addSuggestion("did_you_mean", phraseSuggestion("name").maxErrors(5.0f))
|
.addSuggestion("did_you_mean", phraseSuggestion("name").maxErrors(5.0f))
|
||||||
|
@ -914,8 +910,7 @@ public class SuggestSearchIT extends ESIntegTestCase {
|
||||||
indexDoc("test", "1", "name", "Just testing the suggestions api");
|
indexDoc("test", "1", "name", "Just testing the suggestions api");
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setSize(0)
|
||||||
.setSize(0)
|
|
||||||
.suggest(
|
.suggest(
|
||||||
new SuggestBuilder().setGlobalText("tetsting sugestion")
|
new SuggestBuilder().setGlobalText("tetsting sugestion")
|
||||||
.addSuggestion("did_you_mean", phraseSuggestion("name").maxErrors(5.0f))
|
.addSuggestion("did_you_mean", phraseSuggestion("name").maxErrors(5.0f))
|
||||||
|
@ -1416,7 +1411,7 @@ public class SuggestSearchIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Suggest searchSuggest(String suggestText, int expectShardsFailed, Map<String, SuggestionBuilder<?>> suggestions) {
|
protected Suggest searchSuggest(String suggestText, int expectShardsFailed, Map<String, SuggestionBuilder<?>> suggestions) {
|
||||||
SearchRequestBuilder builder = client().prepareSearch().setSize(0);
|
SearchRequestBuilder builder = prepareSearch().setSize(0);
|
||||||
SuggestBuilder suggestBuilder = new SuggestBuilder();
|
SuggestBuilder suggestBuilder = new SuggestBuilder();
|
||||||
if (suggestText != null) {
|
if (suggestText != null) {
|
||||||
suggestBuilder.setGlobalText(suggestText);
|
suggestBuilder.setGlobalText(suggestText);
|
||||||
|
|
|
@ -55,17 +55,11 @@ public class SimilarityIT extends ESIntegTestCase {
|
||||||
.execute()
|
.execute()
|
||||||
.actionGet();
|
.actionGet();
|
||||||
|
|
||||||
SearchResponse bm25SearchResponse = client().prepareSearch()
|
SearchResponse bm25SearchResponse = prepareSearch().setQuery(matchQuery("field1", "quick brown fox")).execute().actionGet();
|
||||||
.setQuery(matchQuery("field1", "quick brown fox"))
|
|
||||||
.execute()
|
|
||||||
.actionGet();
|
|
||||||
assertThat(bm25SearchResponse.getHits().getTotalHits().value, equalTo(1L));
|
assertThat(bm25SearchResponse.getHits().getTotalHits().value, equalTo(1L));
|
||||||
float bm25Score = bm25SearchResponse.getHits().getHits()[0].getScore();
|
float bm25Score = bm25SearchResponse.getHits().getHits()[0].getScore();
|
||||||
|
|
||||||
SearchResponse booleanSearchResponse = client().prepareSearch()
|
SearchResponse booleanSearchResponse = prepareSearch().setQuery(matchQuery("field2", "quick brown fox")).execute().actionGet();
|
||||||
.setQuery(matchQuery("field2", "quick brown fox"))
|
|
||||||
.execute()
|
|
||||||
.actionGet();
|
|
||||||
assertThat(booleanSearchResponse.getHits().getTotalHits().value, equalTo(1L));
|
assertThat(booleanSearchResponse.getHits().getTotalHits().value, equalTo(1L));
|
||||||
float defaultScore = booleanSearchResponse.getHits().getHits()[0].getScore();
|
float defaultScore = booleanSearchResponse.getHits().getHits()[0].getScore();
|
||||||
|
|
||||||
|
|
|
@ -327,13 +327,13 @@ public class SimpleVersioningIT extends ESIntegTestCase {
|
||||||
// search with versioning
|
// search with versioning
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
// TODO: ADD SEQ NO!
|
// TODO: ADD SEQ NO!
|
||||||
SearchResponse searchResponse = client().prepareSearch().setQuery(matchAllQuery()).setVersion(true).execute().actionGet();
|
SearchResponse searchResponse = prepareSearch().setQuery(matchAllQuery()).setVersion(true).execute().actionGet();
|
||||||
assertThat(searchResponse.getHits().getAt(0).getVersion(), equalTo(2L));
|
assertThat(searchResponse.getHits().getAt(0).getVersion(), equalTo(2L));
|
||||||
}
|
}
|
||||||
|
|
||||||
// search without versioning
|
// search without versioning
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
SearchResponse searchResponse = client().prepareSearch().setQuery(matchAllQuery()).execute().actionGet();
|
SearchResponse searchResponse = prepareSearch().setQuery(matchAllQuery()).execute().actionGet();
|
||||||
assertThat(searchResponse.getHits().getAt(0).getVersion(), equalTo(Versions.NOT_FOUND));
|
assertThat(searchResponse.getHits().getAt(0).getVersion(), equalTo(Versions.NOT_FOUND));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -396,8 +396,7 @@ public class SimpleVersioningIT extends ESIntegTestCase {
|
||||||
client().admin().indices().prepareRefresh().execute().actionGet();
|
client().admin().indices().prepareRefresh().execute().actionGet();
|
||||||
|
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.setVersion(true)
|
.setVersion(true)
|
||||||
.seqNoAndPrimaryTerm(true)
|
.seqNoAndPrimaryTerm(true)
|
||||||
.execute()
|
.execute()
|
||||||
|
|
|
@ -60,9 +60,9 @@ public abstract class CentroidAggregationTestBase extends AbstractGeoTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPartiallyUnmapped() {
|
public void testPartiallyUnmapped() {
|
||||||
SearchResponse response = client().prepareSearch(IDX_NAME, UNMAPPED_IDX_NAME)
|
SearchResponse response = prepareSearch(IDX_NAME, UNMAPPED_IDX_NAME).addAggregation(
|
||||||
.addAggregation(centroidAgg(aggName()).field(SINGLE_VALUED_FIELD_NAME))
|
centroidAgg(aggName()).field(SINGLE_VALUED_FIELD_NAME)
|
||||||
.get();
|
).get();
|
||||||
assertNoFailures(response);
|
assertNoFailures(response);
|
||||||
|
|
||||||
CentroidAggregation geoCentroid = response.getAggregations().get(aggName());
|
CentroidAggregation geoCentroid = response.getAggregations().get(aggName());
|
||||||
|
|
|
@ -127,8 +127,7 @@ public abstract class SpatialBoundsAggregationTestBase<T extends SpatialPoint> e
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPartiallyUnmapped() throws Exception {
|
public void testPartiallyUnmapped() throws Exception {
|
||||||
SearchResponse response = client().prepareSearch(IDX_NAME, UNMAPPED_IDX_NAME)
|
SearchResponse response = prepareSearch(IDX_NAME, UNMAPPED_IDX_NAME).addAggregation(boundsAgg(aggName(), SINGLE_VALUED_FIELD_NAME))
|
||||||
.addAggregation(boundsAgg(aggName(), SINGLE_VALUED_FIELD_NAME))
|
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
assertNoFailures(response);
|
assertNoFailures(response);
|
||||||
|
|
|
@ -303,8 +303,7 @@ public abstract class BaseShapeIntegTestCase<T extends AbstractGeometryQueryBuil
|
||||||
client().admin().indices().prepareRefresh().get();
|
client().admin().indices().prepareRefresh().get();
|
||||||
|
|
||||||
// Point in polygon
|
// Point in polygon
|
||||||
SearchResponse result = client().prepareSearch()
|
SearchResponse result = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.setPostFilter(queryBuilder().intersectionQuery("area", new Point(3, 3)))
|
.setPostFilter(queryBuilder().intersectionQuery("area", new Point(3, 3)))
|
||||||
.get();
|
.get();
|
||||||
assertHitCount(result, 1);
|
assertHitCount(result, 1);
|
||||||
|
@ -312,7 +311,7 @@ public abstract class BaseShapeIntegTestCase<T extends AbstractGeometryQueryBuil
|
||||||
|
|
||||||
// Point in polygon hole
|
// Point in polygon hole
|
||||||
assertHitCount(
|
assertHitCount(
|
||||||
client().prepareSearch().setQuery(matchAllQuery()).setPostFilter(queryBuilder().intersectionQuery("area", new Point(4.5, 4.5))),
|
prepareSearch().setQuery(matchAllQuery()).setPostFilter(queryBuilder().intersectionQuery("area", new Point(4.5, 4.5))),
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -321,32 +320,24 @@ public abstract class BaseShapeIntegTestCase<T extends AbstractGeometryQueryBuil
|
||||||
// of the polygon NOT the hole
|
// of the polygon NOT the hole
|
||||||
|
|
||||||
// Point on polygon border
|
// Point on polygon border
|
||||||
result = client().prepareSearch()
|
result = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.setPostFilter(queryBuilder().intersectionQuery("area", new Point(10.0, 5.0)))
|
.setPostFilter(queryBuilder().intersectionQuery("area", new Point(10.0, 5.0)))
|
||||||
.get();
|
.get();
|
||||||
assertHitCount(result, 1);
|
assertHitCount(result, 1);
|
||||||
assertFirstHit(result, hasId("1"));
|
assertFirstHit(result, hasId("1"));
|
||||||
|
|
||||||
// Point on hole border
|
// Point on hole border
|
||||||
result = client().prepareSearch()
|
result = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.setPostFilter(queryBuilder().intersectionQuery("area", new Point(5.0, 2.0)))
|
.setPostFilter(queryBuilder().intersectionQuery("area", new Point(5.0, 2.0)))
|
||||||
.get();
|
.get();
|
||||||
assertHitCount(result, 1);
|
assertHitCount(result, 1);
|
||||||
assertFirstHit(result, hasId("1"));
|
assertFirstHit(result, hasId("1"));
|
||||||
|
|
||||||
// Point not in polygon
|
// Point not in polygon
|
||||||
assertHitCount(
|
assertHitCount(prepareSearch().setQuery(matchAllQuery()).setPostFilter(queryBuilder().disjointQuery("area", new Point(3, 3))), 0);
|
||||||
client().prepareSearch().setQuery(matchAllQuery()).setPostFilter(queryBuilder().disjointQuery("area", new Point(3, 3))),
|
|
||||||
0
|
|
||||||
);
|
|
||||||
|
|
||||||
// Point in polygon hole
|
// Point in polygon hole
|
||||||
result = client().prepareSearch()
|
result = prepareSearch().setQuery(matchAllQuery()).setPostFilter(queryBuilder().disjointQuery("area", new Point(4.5, 4.5))).get();
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.setPostFilter(queryBuilder().disjointQuery("area", new Point(4.5, 4.5)))
|
|
||||||
.get();
|
|
||||||
assertHitCount(result, 1);
|
assertHitCount(result, 1);
|
||||||
assertFirstHit(result, hasId("1"));
|
assertFirstHit(result, hasId("1"));
|
||||||
|
|
||||||
|
@ -361,8 +352,7 @@ public abstract class BaseShapeIntegTestCase<T extends AbstractGeometryQueryBuil
|
||||||
client().admin().indices().prepareRefresh().get();
|
client().admin().indices().prepareRefresh().get();
|
||||||
|
|
||||||
// re-check point on polygon hole
|
// re-check point on polygon hole
|
||||||
result = client().prepareSearch()
|
result = prepareSearch().setQuery(matchAllQuery())
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.setPostFilter(queryBuilder().intersectionQuery("area", new Point(4.5, 4.5)))
|
.setPostFilter(queryBuilder().intersectionQuery("area", new Point(4.5, 4.5)))
|
||||||
.get();
|
.get();
|
||||||
assertHitCount(result, 1);
|
assertHitCount(result, 1);
|
||||||
|
@ -371,7 +361,7 @@ public abstract class BaseShapeIntegTestCase<T extends AbstractGeometryQueryBuil
|
||||||
// Polygon WithIn Polygon
|
// Polygon WithIn Polygon
|
||||||
Polygon WithIn = new Polygon(new LinearRing(new double[] { -30, -30, 30, 30, -30 }, new double[] { -30, 30, 30, -30, -30 }));
|
Polygon WithIn = new Polygon(new LinearRing(new double[] { -30, -30, 30, 30, -30 }, new double[] { -30, 30, 30, -30, -30 }));
|
||||||
|
|
||||||
assertHitCount(client().prepareSearch().setQuery(matchAllQuery()).setPostFilter(queryBuilder().withinQuery("area", WithIn)), 2);
|
assertHitCount(prepareSearch().setQuery(matchAllQuery()).setPostFilter(queryBuilder().withinQuery("area", WithIn)), 2);
|
||||||
|
|
||||||
// Create a polygon crossing longitude 180.
|
// Create a polygon crossing longitude 180.
|
||||||
Polygon crossing = new Polygon(new LinearRing(new double[] { 170, 190, 190, 170, 170 }, new double[] { -10, -10, 10, 10, -10 }));
|
Polygon crossing = new Polygon(new LinearRing(new double[] { 170, 190, 190, 170, 170 }, new double[] { -10, -10, 10, 10, -10 }));
|
||||||
|
@ -391,24 +381,22 @@ public abstract class BaseShapeIntegTestCase<T extends AbstractGeometryQueryBuil
|
||||||
client().admin().indices().prepareRefresh().get();
|
client().admin().indices().prepareRefresh().get();
|
||||||
|
|
||||||
assertHitCount(
|
assertHitCount(
|
||||||
client().prepareSearch().setQuery(matchAllQuery()).setPostFilter(queryBuilder().intersectionQuery("area", new Point(174, -4))),
|
prepareSearch().setQuery(matchAllQuery()).setPostFilter(queryBuilder().intersectionQuery("area", new Point(174, -4))),
|
||||||
1
|
1
|
||||||
);
|
);
|
||||||
|
|
||||||
// In geo coordinates the polygon wraps the dateline, so we need to search within valid longitude ranges
|
// In geo coordinates the polygon wraps the dateline, so we need to search within valid longitude ranges
|
||||||
double xWrapped = getFieldTypeName().contains("geo") ? -174 : 186;
|
double xWrapped = getFieldTypeName().contains("geo") ? -174 : 186;
|
||||||
assertHitCount(
|
assertHitCount(
|
||||||
client().prepareSearch()
|
prepareSearch().setQuery(matchAllQuery()).setPostFilter(queryBuilder().intersectionQuery("area", new Point(xWrapped, -4))),
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.setPostFilter(queryBuilder().intersectionQuery("area", new Point(xWrapped, -4))),
|
|
||||||
1
|
1
|
||||||
);
|
);
|
||||||
assertHitCount(
|
assertHitCount(
|
||||||
client().prepareSearch().setQuery(matchAllQuery()).setPostFilter(queryBuilder().intersectionQuery("area", new Point(180, -4))),
|
prepareSearch().setQuery(matchAllQuery()).setPostFilter(queryBuilder().intersectionQuery("area", new Point(180, -4))),
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
assertHitCount(
|
assertHitCount(
|
||||||
client().prepareSearch().setQuery(matchAllQuery()).setPostFilter(queryBuilder().intersectionQuery("area", new Point(180, -6))),
|
prepareSearch().setQuery(matchAllQuery()).setPostFilter(queryBuilder().intersectionQuery("area", new Point(180, -6))),
|
||||||
1
|
1
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -437,7 +425,7 @@ public abstract class BaseShapeIntegTestCase<T extends AbstractGeometryQueryBuil
|
||||||
client().admin().indices().prepareRefresh().get();
|
client().admin().indices().prepareRefresh().get();
|
||||||
String key = "DE";
|
String key = "DE";
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch().setQuery(matchQuery("_id", key)).get();
|
SearchResponse searchResponse = prepareSearch().setQuery(matchQuery("_id", key)).get();
|
||||||
|
|
||||||
assertHitCount(searchResponse, 1);
|
assertHitCount(searchResponse, 1);
|
||||||
|
|
||||||
|
|
|
@ -103,7 +103,7 @@ public abstract class GeoBoundingBoxQueryIntegTestCase extends ESIntegTestCase {
|
||||||
|
|
||||||
client().admin().indices().prepareRefresh().get();
|
client().admin().indices().prepareRefresh().get();
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch() // from NY
|
SearchResponse searchResponse = prepareSearch() // from NY
|
||||||
.setQuery(geoBoundingBoxQuery("location").setCorners(40.73, -74.1, 40.717, -73.99))
|
.setQuery(geoBoundingBoxQuery("location").setCorners(40.73, -74.1, 40.717, -73.99))
|
||||||
.get();
|
.get();
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(2L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(2L));
|
||||||
|
@ -112,7 +112,7 @@ public abstract class GeoBoundingBoxQueryIntegTestCase extends ESIntegTestCase {
|
||||||
assertThat(hit.getId(), anyOf(equalTo("1"), equalTo("3"), equalTo("5")));
|
assertThat(hit.getId(), anyOf(equalTo("1"), equalTo("3"), equalTo("5")));
|
||||||
}
|
}
|
||||||
|
|
||||||
searchResponse = client().prepareSearch() // from NY
|
searchResponse = prepareSearch() // from NY
|
||||||
.setQuery(geoBoundingBoxQuery("location").setCorners(40.73, -74.1, 40.717, -73.99))
|
.setQuery(geoBoundingBoxQuery("location").setCorners(40.73, -74.1, 40.717, -73.99))
|
||||||
.get();
|
.get();
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(2L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(2L));
|
||||||
|
@ -121,7 +121,7 @@ public abstract class GeoBoundingBoxQueryIntegTestCase extends ESIntegTestCase {
|
||||||
assertThat(hit.getId(), anyOf(equalTo("1"), equalTo("3"), equalTo("5")));
|
assertThat(hit.getId(), anyOf(equalTo("1"), equalTo("3"), equalTo("5")));
|
||||||
}
|
}
|
||||||
|
|
||||||
searchResponse = client().prepareSearch() // top == bottom && left == right
|
searchResponse = prepareSearch() // top == bottom && left == right
|
||||||
.setQuery(geoBoundingBoxQuery("location").setCorners(40.7143528, -74.0059731, 40.7143528, -74.0059731))
|
.setQuery(geoBoundingBoxQuery("location").setCorners(40.7143528, -74.0059731, 40.7143528, -74.0059731))
|
||||||
.get();
|
.get();
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
||||||
|
@ -130,7 +130,7 @@ public abstract class GeoBoundingBoxQueryIntegTestCase extends ESIntegTestCase {
|
||||||
assertThat(hit.getId(), equalTo("1"));
|
assertThat(hit.getId(), equalTo("1"));
|
||||||
}
|
}
|
||||||
|
|
||||||
searchResponse = client().prepareSearch() // top == bottom
|
searchResponse = prepareSearch() // top == bottom
|
||||||
.setQuery(geoBoundingBoxQuery("location").setCorners(40.759011, -74.00009, 40.759011, -73.0059731))
|
.setQuery(geoBoundingBoxQuery("location").setCorners(40.759011, -74.00009, 40.759011, -73.0059731))
|
||||||
.get();
|
.get();
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
||||||
|
@ -139,7 +139,7 @@ public abstract class GeoBoundingBoxQueryIntegTestCase extends ESIntegTestCase {
|
||||||
assertThat(hit.getId(), equalTo("2"));
|
assertThat(hit.getId(), equalTo("2"));
|
||||||
}
|
}
|
||||||
|
|
||||||
searchResponse = client().prepareSearch() // left == right
|
searchResponse = prepareSearch() // left == right
|
||||||
.setQuery(geoBoundingBoxQuery("location").setCorners(41.8, -73.9844722, 40.7, -73.9844722))
|
.setQuery(geoBoundingBoxQuery("location").setCorners(41.8, -73.9844722, 40.7, -73.9844722))
|
||||||
.get();
|
.get();
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
||||||
|
@ -149,7 +149,7 @@ public abstract class GeoBoundingBoxQueryIntegTestCase extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Distance query
|
// Distance query
|
||||||
searchResponse = client().prepareSearch() // from NY
|
searchResponse = prepareSearch() // from NY
|
||||||
.setQuery(geoDistanceQuery("location").point(40.5, -73.9).distance(25, DistanceUnit.KILOMETERS))
|
.setQuery(geoDistanceQuery("location").point(40.5, -73.9).distance(25, DistanceUnit.KILOMETERS))
|
||||||
.get();
|
.get();
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(2L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(2L));
|
||||||
|
@ -189,120 +189,96 @@ public abstract class GeoBoundingBoxQueryIntegTestCase extends ESIntegTestCase {
|
||||||
.setRefreshPolicy(IMMEDIATE)
|
.setRefreshPolicy(IMMEDIATE)
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(
|
||||||
.setQuery(
|
boolQuery().must(termQuery("userid", 880))
|
||||||
boolQuery().must(termQuery("userid", 880))
|
.filter(geoBoundingBoxQuery("location").setCorners(74.579421999999994, 143.5, -66.668903999999998, 113.96875))
|
||||||
.filter(geoBoundingBoxQuery("location").setCorners(74.579421999999994, 143.5, -66.668903999999998, 113.96875))
|
).get();
|
||||||
)
|
|
||||||
.get();
|
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(
|
||||||
.setQuery(
|
boolQuery().must(termQuery("userid", 880))
|
||||||
boolQuery().must(termQuery("userid", 880))
|
.filter(geoBoundingBoxQuery("location").setCorners(74.579421999999994, 143.5, -66.668903999999998, 113.96875))
|
||||||
.filter(geoBoundingBoxQuery("location").setCorners(74.579421999999994, 143.5, -66.668903999999998, 113.96875))
|
).get();
|
||||||
)
|
|
||||||
.get();
|
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
||||||
|
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(
|
||||||
.setQuery(
|
boolQuery().must(termQuery("userid", 534))
|
||||||
boolQuery().must(termQuery("userid", 534))
|
.filter(geoBoundingBoxQuery("location").setCorners(74.579421999999994, 143.5, -66.668903999999998, 113.96875))
|
||||||
.filter(geoBoundingBoxQuery("location").setCorners(74.579421999999994, 143.5, -66.668903999999998, 113.96875))
|
).get();
|
||||||
)
|
|
||||||
.get();
|
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(
|
||||||
.setQuery(
|
boolQuery().must(termQuery("userid", 534))
|
||||||
boolQuery().must(termQuery("userid", 534))
|
.filter(geoBoundingBoxQuery("location").setCorners(74.579421999999994, 143.5, -66.668903999999998, 113.96875))
|
||||||
.filter(geoBoundingBoxQuery("location").setCorners(74.579421999999994, 143.5, -66.668903999999998, 113.96875))
|
).get();
|
||||||
)
|
|
||||||
.get();
|
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
||||||
|
|
||||||
// top == bottom && left == right
|
// top == bottom && left == right
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(
|
||||||
.setQuery(
|
boolQuery().must(termQuery("userid", 880))
|
||||||
boolQuery().must(termQuery("userid", 880))
|
.filter(geoBoundingBoxQuery("location").setCorners(18.036842, 59.328355000000002, 18.036842, 59.328355000000002))
|
||||||
.filter(geoBoundingBoxQuery("location").setCorners(18.036842, 59.328355000000002, 18.036842, 59.328355000000002))
|
).get();
|
||||||
)
|
|
||||||
.get();
|
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(
|
||||||
.setQuery(
|
boolQuery().must(termQuery("userid", 534))
|
||||||
boolQuery().must(termQuery("userid", 534))
|
.filter(
|
||||||
.filter(
|
geoBoundingBoxQuery("location").setCorners(
|
||||||
geoBoundingBoxQuery("location").setCorners(
|
45.509526999999999,
|
||||||
45.509526999999999,
|
-73.570986000000005,
|
||||||
-73.570986000000005,
|
45.509526999999999,
|
||||||
45.509526999999999,
|
-73.570986000000005
|
||||||
-73.570986000000005
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.get();
|
).get();
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
||||||
|
|
||||||
// top == bottom
|
// top == bottom
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(
|
||||||
.setQuery(
|
boolQuery().must(termQuery("userid", 880))
|
||||||
boolQuery().must(termQuery("userid", 880))
|
.filter(geoBoundingBoxQuery("location").setCorners(18.036842, 143.5, 18.036842, 113.96875))
|
||||||
.filter(geoBoundingBoxQuery("location").setCorners(18.036842, 143.5, 18.036842, 113.96875))
|
).get();
|
||||||
)
|
|
||||||
.get();
|
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(
|
||||||
.setQuery(
|
boolQuery().must(termQuery("userid", 534))
|
||||||
boolQuery().must(termQuery("userid", 534))
|
.filter(geoBoundingBoxQuery("location").setCorners(45.509526999999999, 143.5, 45.509526999999999, 113.96875))
|
||||||
.filter(geoBoundingBoxQuery("location").setCorners(45.509526999999999, 143.5, 45.509526999999999, 113.96875))
|
).get();
|
||||||
)
|
|
||||||
.get();
|
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
||||||
|
|
||||||
// left == right
|
// left == right
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(
|
||||||
.setQuery(
|
boolQuery().must(termQuery("userid", 880))
|
||||||
boolQuery().must(termQuery("userid", 880))
|
.filter(
|
||||||
.filter(
|
geoBoundingBoxQuery("location").setCorners(
|
||||||
geoBoundingBoxQuery("location").setCorners(
|
74.579421999999994,
|
||||||
74.579421999999994,
|
59.328355000000002,
|
||||||
59.328355000000002,
|
-66.668903999999998,
|
||||||
-66.668903999999998,
|
59.328355000000002
|
||||||
59.328355000000002
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.get();
|
).get();
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(
|
||||||
.setQuery(
|
boolQuery().must(termQuery("userid", 534))
|
||||||
boolQuery().must(termQuery("userid", 534))
|
.filter(
|
||||||
.filter(
|
geoBoundingBoxQuery("location").setCorners(
|
||||||
geoBoundingBoxQuery("location").setCorners(
|
74.579421999999994,
|
||||||
74.579421999999994,
|
-73.570986000000005,
|
||||||
-73.570986000000005,
|
-66.668903999999998,
|
||||||
-66.668903999999998,
|
-73.570986000000005
|
||||||
-73.570986000000005
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.get();
|
).get();
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
||||||
|
|
||||||
// Distance query
|
// Distance query
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(
|
||||||
.setQuery(
|
boolQuery().must(termQuery("userid", 880))
|
||||||
boolQuery().must(termQuery("userid", 880))
|
.filter(geoDistanceQuery("location").point(20, 60.0).distance(500, DistanceUnit.MILES))
|
||||||
.filter(geoDistanceQuery("location").point(20, 60.0).distance(500, DistanceUnit.MILES))
|
).get();
|
||||||
)
|
|
||||||
.get();
|
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
||||||
|
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(
|
||||||
.setQuery(
|
boolQuery().must(termQuery("userid", 534))
|
||||||
boolQuery().must(termQuery("userid", 534))
|
.filter(geoDistanceQuery("location").point(45.0, -73.0).distance(500, DistanceUnit.MILES))
|
||||||
.filter(geoDistanceQuery("location").point(45.0, -73.0).distance(500, DistanceUnit.MILES))
|
).get();
|
||||||
)
|
|
||||||
.get();
|
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -336,60 +312,54 @@ public abstract class GeoBoundingBoxQueryIntegTestCase extends ESIntegTestCase {
|
||||||
.setRefreshPolicy(IMMEDIATE)
|
.setRefreshPolicy(IMMEDIATE)
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(
|
||||||
.setQuery(geoBoundingBoxQuery("location").setValidationMethod(GeoValidationMethod.COERCE).setCorners(50, -180, -50, 180))
|
geoBoundingBoxQuery("location").setValidationMethod(GeoValidationMethod.COERCE).setCorners(50, -180, -50, 180)
|
||||||
.get();
|
).get();
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(
|
||||||
.setQuery(geoBoundingBoxQuery("location").setValidationMethod(GeoValidationMethod.COERCE).setCorners(50, -180, -50, 180))
|
geoBoundingBoxQuery("location").setValidationMethod(GeoValidationMethod.COERCE).setCorners(50, -180, -50, 180)
|
||||||
.get();
|
).get();
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(
|
||||||
.setQuery(geoBoundingBoxQuery("location").setValidationMethod(GeoValidationMethod.COERCE).setCorners(90, -180, -90, 180))
|
geoBoundingBoxQuery("location").setValidationMethod(GeoValidationMethod.COERCE).setCorners(90, -180, -90, 180)
|
||||||
.get();
|
).get();
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(2L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(2L));
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(
|
||||||
.setQuery(geoBoundingBoxQuery("location").setValidationMethod(GeoValidationMethod.COERCE).setCorners(90, -180, -90, 180))
|
geoBoundingBoxQuery("location").setValidationMethod(GeoValidationMethod.COERCE).setCorners(90, -180, -90, 180)
|
||||||
.get();
|
).get();
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(2L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(2L));
|
||||||
|
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(
|
||||||
.setQuery(geoBoundingBoxQuery("location").setValidationMethod(GeoValidationMethod.COERCE).setCorners(50, 0, -50, 360))
|
geoBoundingBoxQuery("location").setValidationMethod(GeoValidationMethod.COERCE).setCorners(50, 0, -50, 360)
|
||||||
.get();
|
).get();
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(
|
||||||
.setQuery(geoBoundingBoxQuery("location").setValidationMethod(GeoValidationMethod.COERCE).setCorners(50, 0, -50, 360))
|
geoBoundingBoxQuery("location").setValidationMethod(GeoValidationMethod.COERCE).setCorners(50, 0, -50, 360)
|
||||||
.get();
|
).get();
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(
|
||||||
.setQuery(geoBoundingBoxQuery("location").setValidationMethod(GeoValidationMethod.COERCE).setCorners(90, 0, -90, 360))
|
geoBoundingBoxQuery("location").setValidationMethod(GeoValidationMethod.COERCE).setCorners(90, 0, -90, 360)
|
||||||
.get();
|
).get();
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(2L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(2L));
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(
|
||||||
.setQuery(geoBoundingBoxQuery("location").setValidationMethod(GeoValidationMethod.COERCE).setCorners(90, 0, -90, 360))
|
geoBoundingBoxQuery("location").setValidationMethod(GeoValidationMethod.COERCE).setCorners(90, 0, -90, 360)
|
||||||
.get();
|
).get();
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(2L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(2L));
|
||||||
|
|
||||||
// top == bottom
|
// top == bottom
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(
|
||||||
.setQuery(
|
geoBoundingBoxQuery("location").setValidationMethod(GeoValidationMethod.COERCE)
|
||||||
geoBoundingBoxQuery("location").setValidationMethod(GeoValidationMethod.COERCE)
|
.setCorners(59.328355000000002, 0, 59.328355000000002, 360)
|
||||||
.setCorners(59.328355000000002, 0, 59.328355000000002, 360)
|
).get();
|
||||||
)
|
|
||||||
.get();
|
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(
|
||||||
.setQuery(
|
geoBoundingBoxQuery("location").setValidationMethod(GeoValidationMethod.COERCE)
|
||||||
geoBoundingBoxQuery("location").setValidationMethod(GeoValidationMethod.COERCE)
|
.setCorners(59.328355000000002, -180, 59.328355000000002, 180)
|
||||||
.setCorners(59.328355000000002, -180, 59.328355000000002, 180)
|
).get();
|
||||||
)
|
|
||||||
.get();
|
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
||||||
|
|
||||||
// Distance query
|
// Distance query
|
||||||
searchResponse = client().prepareSearch()
|
searchResponse = prepareSearch().setQuery(geoDistanceQuery("location").point(60.0, -20.0).distance(1800, DistanceUnit.MILES)).get();
|
||||||
.setQuery(geoDistanceQuery("location").point(60.0, -20.0).distance(1800, DistanceUnit.MILES))
|
|
||||||
.get();
|
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,12 +73,11 @@ public abstract class GeoShapeIntegTestCase extends BaseShapeIntegTestCase<GeoSh
|
||||||
/** The testBulk method uses this only for Geo-specific tests */
|
/** The testBulk method uses this only for Geo-specific tests */
|
||||||
protected void doDistanceAndBoundingBoxTest(String key) {
|
protected void doDistanceAndBoundingBoxTest(String key) {
|
||||||
assertHitCount(
|
assertHitCount(
|
||||||
client().prepareSearch().addStoredField("pin").setQuery(geoBoundingBoxQuery("pin").setCorners(90, -179.99999, -90, 179.99999)),
|
prepareSearch().addStoredField("pin").setQuery(geoBoundingBoxQuery("pin").setCorners(90, -179.99999, -90, 179.99999)),
|
||||||
53
|
53
|
||||||
);
|
);
|
||||||
|
|
||||||
SearchResponse distance = client().prepareSearch()
|
SearchResponse distance = prepareSearch().addStoredField("pin")
|
||||||
.addStoredField("pin")
|
|
||||||
.setQuery(geoDistanceQuery("pin").distance("425km").point(51.11, 9.851))
|
.setQuery(geoDistanceQuery("pin").distance("425km").point(51.11, 9.851))
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
|
|
|
@ -234,8 +234,7 @@ public class FrozenIndexIT extends ESIntegTestCase {
|
||||||
).keepAlive(TimeValue.timeValueMinutes(2));
|
).keepAlive(TimeValue.timeValueMinutes(2));
|
||||||
final String pitId = client().execute(OpenPointInTimeAction.INSTANCE, openPointInTimeRequest).actionGet().getPointInTimeId();
|
final String pitId = client().execute(OpenPointInTimeAction.INSTANCE, openPointInTimeRequest).actionGet().getPointInTimeId();
|
||||||
try {
|
try {
|
||||||
SearchResponse resp = client().prepareSearch()
|
SearchResponse resp = prepareSearch().setIndices(indexName)
|
||||||
.setIndices(indexName)
|
|
||||||
.setPreference(null)
|
.setPreference(null)
|
||||||
.setPointInTime(new PointInTimeBuilder(pitId))
|
.setPointInTime(new PointInTimeBuilder(pitId))
|
||||||
.get();
|
.get();
|
||||||
|
@ -244,8 +243,7 @@ public class FrozenIndexIT extends ESIntegTestCase {
|
||||||
assertHitCount(resp, numDocs);
|
assertHitCount(resp, numDocs);
|
||||||
internalCluster().restartNode(assignedNode);
|
internalCluster().restartNode(assignedNode);
|
||||||
ensureGreen(indexName);
|
ensureGreen(indexName);
|
||||||
resp = client().prepareSearch()
|
resp = prepareSearch().setIndices(indexName)
|
||||||
.setIndices(indexName)
|
|
||||||
.setQuery(new RangeQueryBuilder("created_date").gte("2011-01-01").lte("2011-12-12"))
|
.setQuery(new RangeQueryBuilder("created_date").gte("2011-01-01").lte("2011-12-12"))
|
||||||
.setSearchType(SearchType.QUERY_THEN_FETCH)
|
.setSearchType(SearchType.QUERY_THEN_FETCH)
|
||||||
.setPreference(null)
|
.setPreference(null)
|
||||||
|
@ -287,8 +285,7 @@ public class FrozenIndexIT extends ESIntegTestCase {
|
||||||
try {
|
try {
|
||||||
indicesAdmin().prepareDelete("index-1").get();
|
indicesAdmin().prepareDelete("index-1").get();
|
||||||
// Return partial results if allow partial search result is allowed
|
// Return partial results if allow partial search result is allowed
|
||||||
SearchResponse resp = client().prepareSearch()
|
SearchResponse resp = prepareSearch().setPreference(null)
|
||||||
.setPreference(null)
|
|
||||||
.setAllowPartialSearchResults(true)
|
.setAllowPartialSearchResults(true)
|
||||||
.setPointInTime(new PointInTimeBuilder(pitId))
|
.setPointInTime(new PointInTimeBuilder(pitId))
|
||||||
.get();
|
.get();
|
||||||
|
@ -297,10 +294,7 @@ public class FrozenIndexIT extends ESIntegTestCase {
|
||||||
// Fails if allow partial search result is not allowed
|
// Fails if allow partial search result is not allowed
|
||||||
expectThrows(
|
expectThrows(
|
||||||
ElasticsearchException.class,
|
ElasticsearchException.class,
|
||||||
client().prepareSearch()
|
prepareSearch().setPreference(null).setAllowPartialSearchResults(false).setPointInTime(new PointInTimeBuilder(pitId))::get
|
||||||
.setPreference(null)
|
|
||||||
.setAllowPartialSearchResults(false)
|
|
||||||
.setPointInTime(new PointInTimeBuilder(pitId))::get
|
|
||||||
);
|
);
|
||||||
} finally {
|
} finally {
|
||||||
client().execute(ClosePointInTimeAction.INSTANCE, new ClosePointInTimeRequest(pitId)).actionGet();
|
client().execute(ClosePointInTimeAction.INSTANCE, new ClosePointInTimeRequest(pitId)).actionGet();
|
||||||
|
@ -323,7 +317,7 @@ public class FrozenIndexIT extends ESIntegTestCase {
|
||||||
).keepAlive(TimeValue.timeValueMinutes(2));
|
).keepAlive(TimeValue.timeValueMinutes(2));
|
||||||
final String pitId = client().execute(OpenPointInTimeAction.INSTANCE, openPointInTimeRequest).actionGet().getPointInTimeId();
|
final String pitId = client().execute(OpenPointInTimeAction.INSTANCE, openPointInTimeRequest).actionGet().getPointInTimeId();
|
||||||
try {
|
try {
|
||||||
SearchResponse resp = client().prepareSearch().setPreference(null).setPointInTime(new PointInTimeBuilder(pitId)).get();
|
SearchResponse resp = prepareSearch().setPreference(null).setPointInTime(new PointInTimeBuilder(pitId)).get();
|
||||||
assertNoFailures(resp);
|
assertNoFailures(resp);
|
||||||
assertHitCount(resp, numDocs);
|
assertHitCount(resp, numDocs);
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -337,7 +331,7 @@ public class FrozenIndexIT extends ESIntegTestCase {
|
||||||
);
|
);
|
||||||
final String pitId = client().execute(OpenPointInTimeAction.INSTANCE, openPointInTimeRequest).actionGet().getPointInTimeId();
|
final String pitId = client().execute(OpenPointInTimeAction.INSTANCE, openPointInTimeRequest).actionGet().getPointInTimeId();
|
||||||
try {
|
try {
|
||||||
SearchResponse resp = client().prepareSearch().setPreference(null).setPointInTime(new PointInTimeBuilder(pitId)).get();
|
SearchResponse resp = prepareSearch().setPreference(null).setPointInTime(new PointInTimeBuilder(pitId)).get();
|
||||||
assertNoFailures(resp);
|
assertNoFailures(resp);
|
||||||
assertHitCount(resp, 0);
|
assertHitCount(resp, 0);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
@ -295,11 +295,7 @@ public class UnsignedLongTests extends ESIntegTestCase {
|
||||||
public void testSortDifferentFormatsShouldFail() {
|
public void testSortDifferentFormatsShouldFail() {
|
||||||
Exception exception = expectThrows(
|
Exception exception = expectThrows(
|
||||||
SearchPhaseExecutionException.class,
|
SearchPhaseExecutionException.class,
|
||||||
() -> client().prepareSearch()
|
() -> prepareSearch().setIndices("idx", "idx2").setQuery(QueryBuilders.matchAllQuery()).addSort("ul_field", SortOrder.ASC).get()
|
||||||
.setIndices("idx", "idx2")
|
|
||||||
.setQuery(QueryBuilders.matchAllQuery())
|
|
||||||
.addSort("ul_field", SortOrder.ASC)
|
|
||||||
.get()
|
|
||||||
);
|
);
|
||||||
assertEquals(
|
assertEquals(
|
||||||
exception.getCause().getMessage(),
|
exception.getCause().getMessage(),
|
||||||
|
|
|
@ -203,8 +203,7 @@ public class JobStorageDeletionTaskIT extends BaseMlIntegTestCase {
|
||||||
|
|
||||||
// Make sure all results referencing the dedicated job are gone
|
// Make sure all results referencing the dedicated job are gone
|
||||||
assertThat(
|
assertThat(
|
||||||
client().prepareSearch()
|
prepareSearch().setIndices(AnomalyDetectorsIndex.jobResultsIndexPrefix() + "*")
|
||||||
.setIndices(AnomalyDetectorsIndex.jobResultsIndexPrefix() + "*")
|
|
||||||
.setIndicesOptions(IndicesOptions.lenientExpandOpenHidden())
|
.setIndicesOptions(IndicesOptions.lenientExpandOpenHidden())
|
||||||
.setTrackTotalHits(true)
|
.setTrackTotalHits(true)
|
||||||
.setSize(0)
|
.setSize(0)
|
||||||
|
|
|
@ -751,8 +751,7 @@ public class MlDistributedFailureIT extends BaseMlIntegTestCase {
|
||||||
// so when restarting job on another node the data counts
|
// so when restarting job on another node the data counts
|
||||||
// are what we expect them to be:
|
// are what we expect them to be:
|
||||||
private static DataCounts getDataCountsFromIndex(String jobId) {
|
private static DataCounts getDataCountsFromIndex(String jobId) {
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setIndicesOptions(IndicesOptions.LENIENT_EXPAND_OPEN_CLOSED_HIDDEN)
|
||||||
.setIndicesOptions(IndicesOptions.LENIENT_EXPAND_OPEN_CLOSED_HIDDEN)
|
|
||||||
.setQuery(QueryBuilders.idsQuery().addIds(DataCounts.documentId(jobId)))
|
.setQuery(QueryBuilders.idsQuery().addIds(DataCounts.documentId(jobId)))
|
||||||
.get();
|
.get();
|
||||||
if (searchResponse.getHits().getTotalHits().value != 1) {
|
if (searchResponse.getHits().getTotalHits().value != 1) {
|
||||||
|
|
|
@ -113,8 +113,7 @@ public class PinnedQueryBuilderIT extends ESIntegTestCase {
|
||||||
private void assertPinnedPromotions(PinnedQueryBuilder pqb, LinkedHashSet<String> pins, int iter, int numRelevantDocs) {
|
private void assertPinnedPromotions(PinnedQueryBuilder pqb, LinkedHashSet<String> pins, int iter, int numRelevantDocs) {
|
||||||
int from = randomIntBetween(0, numRelevantDocs);
|
int from = randomIntBetween(0, numRelevantDocs);
|
||||||
int size = randomIntBetween(10, 100);
|
int size = randomIntBetween(10, 100);
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(pqb)
|
||||||
.setQuery(pqb)
|
|
||||||
.setTrackTotalHits(true)
|
.setTrackTotalHits(true)
|
||||||
.setSize(size)
|
.setSize(size)
|
||||||
.setFrom(from)
|
.setFrom(from)
|
||||||
|
@ -194,11 +193,7 @@ public class PinnedQueryBuilderIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertExhaustiveScoring(PinnedQueryBuilder pqb) {
|
private void assertExhaustiveScoring(PinnedQueryBuilder pqb) {
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(pqb).setTrackTotalHits(true).setSearchType(DFS_QUERY_THEN_FETCH).get();
|
||||||
.setQuery(pqb)
|
|
||||||
.setTrackTotalHits(true)
|
|
||||||
.setSearchType(DFS_QUERY_THEN_FETCH)
|
|
||||||
.get();
|
|
||||||
|
|
||||||
long numHits = searchResponse.getHits().getTotalHits().value;
|
long numHits = searchResponse.getHits().getTotalHits().value;
|
||||||
assertThat(numHits, equalTo(2L));
|
assertThat(numHits, equalTo(2L));
|
||||||
|
@ -232,11 +227,7 @@ public class PinnedQueryBuilderIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertExplain(PinnedQueryBuilder pqb) {
|
private void assertExplain(PinnedQueryBuilder pqb) {
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setSearchType(SearchType.DFS_QUERY_THEN_FETCH).setQuery(pqb).setExplain(true).get();
|
||||||
.setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
|
|
||||||
.setQuery(pqb)
|
|
||||||
.setExplain(true)
|
|
||||||
.get();
|
|
||||||
assertHitCount(searchResponse, 3);
|
assertHitCount(searchResponse, 3);
|
||||||
assertFirstHit(searchResponse, hasId("2"));
|
assertFirstHit(searchResponse, hasId("2"));
|
||||||
assertSecondHit(searchResponse, hasId("1"));
|
assertSecondHit(searchResponse, hasId("1"));
|
||||||
|
@ -280,8 +271,7 @@ public class PinnedQueryBuilderIT extends ESIntegTestCase {
|
||||||
HighlightBuilder testHighlighter = new HighlightBuilder();
|
HighlightBuilder testHighlighter = new HighlightBuilder();
|
||||||
testHighlighter.field("field1");
|
testHighlighter.field("field1");
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
|
||||||
.setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
|
|
||||||
.setQuery(pqb)
|
.setQuery(pqb)
|
||||||
.highlighter(testHighlighter)
|
.highlighter(testHighlighter)
|
||||||
.setExplain(true)
|
.setExplain(true)
|
||||||
|
@ -340,11 +330,7 @@ public class PinnedQueryBuilderIT extends ESIntegTestCase {
|
||||||
new Item("test1", "b")
|
new Item("test1", "b")
|
||||||
);
|
);
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(pqb).setTrackTotalHits(true).setSearchType(DFS_QUERY_THEN_FETCH).get();
|
||||||
.setQuery(pqb)
|
|
||||||
.setTrackTotalHits(true)
|
|
||||||
.setSearchType(DFS_QUERY_THEN_FETCH)
|
|
||||||
.get();
|
|
||||||
|
|
||||||
assertHitCount(searchResponse, 4);
|
assertHitCount(searchResponse, 4);
|
||||||
assertFirstHit(searchResponse, both(hasIndex("test2")).and(hasId("a")));
|
assertFirstHit(searchResponse, both(hasIndex("test2")).and(hasId("a")));
|
||||||
|
@ -384,11 +370,7 @@ public class PinnedQueryBuilderIT extends ESIntegTestCase {
|
||||||
new Item("test", "a")
|
new Item("test", "a")
|
||||||
);
|
);
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(pqb).setTrackTotalHits(true).setSearchType(DFS_QUERY_THEN_FETCH).get();
|
||||||
.setQuery(pqb)
|
|
||||||
.setTrackTotalHits(true)
|
|
||||||
.setSearchType(DFS_QUERY_THEN_FETCH)
|
|
||||||
.get();
|
|
||||||
|
|
||||||
assertHitCount(searchResponse, 3);
|
assertHitCount(searchResponse, 3);
|
||||||
assertFirstHit(searchResponse, both(hasIndex("test")).and(hasId("b")));
|
assertFirstHit(searchResponse, both(hasIndex("test")).and(hasId("b")));
|
||||||
|
@ -446,11 +428,7 @@ public class PinnedQueryBuilderIT extends ESIntegTestCase {
|
||||||
new Item("test-alias", "a")
|
new Item("test-alias", "a")
|
||||||
);
|
);
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = prepareSearch().setQuery(pqb).setTrackTotalHits(true).setSearchType(DFS_QUERY_THEN_FETCH).get();
|
||||||
.setQuery(pqb)
|
|
||||||
.setTrackTotalHits(true)
|
|
||||||
.setSearchType(DFS_QUERY_THEN_FETCH)
|
|
||||||
.get();
|
|
||||||
|
|
||||||
assertHitCount(searchResponse, 4);
|
assertHitCount(searchResponse, 4);
|
||||||
assertFirstHit(searchResponse, both(hasIndex("test1")).and(hasId("b")));
|
assertFirstHit(searchResponse, both(hasIndex("test1")).and(hasId("b")));
|
||||||
|
|
|
@ -144,8 +144,7 @@ public class RetrySearchIntegTests extends BaseSearchableSnapshotsIntegTestCase
|
||||||
).keepAlive(TimeValue.timeValueMinutes(2));
|
).keepAlive(TimeValue.timeValueMinutes(2));
|
||||||
final String pitId = client().execute(OpenPointInTimeAction.INSTANCE, openRequest).actionGet().getPointInTimeId();
|
final String pitId = client().execute(OpenPointInTimeAction.INSTANCE, openRequest).actionGet().getPointInTimeId();
|
||||||
try {
|
try {
|
||||||
SearchResponse resp = client().prepareSearch()
|
SearchResponse resp = prepareSearch().setIndices(indexName)
|
||||||
.setIndices(indexName)
|
|
||||||
.setPreference(null)
|
.setPreference(null)
|
||||||
.setPointInTime(new PointInTimeBuilder(pitId))
|
.setPointInTime(new PointInTimeBuilder(pitId))
|
||||||
.get();
|
.get();
|
||||||
|
@ -158,8 +157,7 @@ public class RetrySearchIntegTests extends BaseSearchableSnapshotsIntegTestCase
|
||||||
internalCluster().restartNode(allocatedNode);
|
internalCluster().restartNode(allocatedNode);
|
||||||
}
|
}
|
||||||
ensureGreen(indexName);
|
ensureGreen(indexName);
|
||||||
resp = client().prepareSearch()
|
resp = prepareSearch().setIndices(indexName)
|
||||||
.setIndices(indexName)
|
|
||||||
.setQuery(new RangeQueryBuilder("created_date").gte("2011-01-01").lte("2011-12-12"))
|
.setQuery(new RangeQueryBuilder("created_date").gte("2011-01-01").lte("2011-12-12"))
|
||||||
.setSearchType(SearchType.QUERY_THEN_FETCH)
|
.setSearchType(SearchType.QUERY_THEN_FETCH)
|
||||||
.setPreference(null)
|
.setPreference(null)
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue