mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-06-29 09:54:06 -04:00
Merge branch 'master' into enhancement/lucene_5_0_upgrade
This commit is contained in:
commit
d4e2f6dfe7
3 changed files with 112 additions and 129 deletions
|
@ -19,8 +19,6 @@
|
|||
|
||||
package org.elasticsearch.cluster.routing;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
import org.elasticsearch.action.admin.indices.get.GetIndexResponse;
|
||||
import org.elasticsearch.action.admin.indices.settings.get.GetSettingsResponse;
|
||||
import org.elasticsearch.action.get.GetResponse;
|
||||
|
@ -40,7 +38,6 @@ import java.io.File;
|
|||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
|
||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse;
|
||||
|
||||
@Ignore
|
||||
@ElasticsearchIntegrationTest.ClusterScope(scope = ElasticsearchIntegrationTest.Scope.TEST, numDataNodes = 0, minNumDataNodes = 0, maxNumDataNodes = 0)
|
||||
public class RoutingBackwardCompatibilityUponUpgradeTests extends ElasticsearchIntegrationTest {
|
||||
|
||||
|
|
|
@ -121,86 +121,75 @@ public class TransportTwoNodesSearchTests extends ElasticsearchIntegrationTest {
|
|||
public void testDfsQueryThenFetch() throws Exception {
|
||||
prepareData();
|
||||
|
||||
SearchSourceBuilder source = searchSource()
|
||||
.query(termQuery("multi", "test"))
|
||||
.from(0).size(60).explain(true);
|
||||
|
||||
SearchResponse searchResponse = client().search(searchRequest("test").source(source).searchType(DFS_QUERY_THEN_FETCH).scroll(new Scroll(timeValueMinutes(10)))).actionGet();
|
||||
int total = 0;
|
||||
SearchResponse searchResponse = client().prepareSearch("test").setSearchType(DFS_QUERY_THEN_FETCH).setQuery(termQuery("multi", "test")).setSize(60).setExplain(true).setScroll(TimeValue.timeValueSeconds(30)).get();
|
||||
while (true) {
|
||||
assertNoFailures(searchResponse);
|
||||
|
||||
assertThat(searchResponse.getHits().totalHits(), equalTo(100l));
|
||||
assertThat(searchResponse.getHits().hits().length, equalTo(60));
|
||||
for (int i = 0; i < 60; i++) {
|
||||
SearchHit hit = searchResponse.getHits().hits()[i];
|
||||
SearchHit[] hits = searchResponse.getHits().hits();
|
||||
if (hits.length == 0) {
|
||||
break; // finished
|
||||
}
|
||||
for (int i = 0; i < hits.length; ++i) {
|
||||
SearchHit hit = hits[i];
|
||||
assertThat(hit.explanation(), notNullValue());
|
||||
assertThat("id[" + hit.id() + "]", hit.id(), equalTo(Integer.toString(100 - i - 1)));
|
||||
assertThat("id[" + hit.id() + "]", hit.id(), equalTo(Integer.toString(100 - total - i - 1)));
|
||||
}
|
||||
|
||||
searchResponse = client().searchScroll(searchScrollRequest(searchResponse.getScrollId())).actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().totalHits(), equalTo(100l));
|
||||
assertThat(searchResponse.getHits().hits().length, equalTo(40));
|
||||
for (int i = 0; i < 40; i++) {
|
||||
SearchHit hit = searchResponse.getHits().hits()[i];
|
||||
assertThat("id[" + hit.id() + "]", hit.id(), equalTo(Integer.toString(100 - 60 - 1 - i)));
|
||||
total += hits.length;
|
||||
searchResponse = client().prepareSearchScroll(searchResponse.getScrollId()).setScroll(TimeValue.timeValueSeconds(30)).get();
|
||||
}
|
||||
clearScroll(searchResponse.getScrollId());
|
||||
assertEquals(100, total);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDfsQueryThenFetchWithSort() throws Exception {
|
||||
prepareData();
|
||||
|
||||
SearchSourceBuilder source = searchSource()
|
||||
.query(termQuery("multi", "test"))
|
||||
.from(0).size(60).explain(true).sort("age", SortOrder.ASC);
|
||||
|
||||
SearchResponse searchResponse = client().search(searchRequest("test").source(source).searchType(DFS_QUERY_THEN_FETCH).scroll(new Scroll(timeValueMinutes(10)))).actionGet();
|
||||
int total = 0;
|
||||
SearchResponse searchResponse = client().prepareSearch("test").setSearchType(DFS_QUERY_THEN_FETCH).setQuery(termQuery("multi", "test")).setSize(60).setExplain(true).addSort("age", SortOrder.ASC).setScroll(TimeValue.timeValueSeconds(30)).get();
|
||||
while (true) {
|
||||
assertNoFailures(searchResponse);
|
||||
assertThat(searchResponse.getHits().totalHits(), equalTo(100l));
|
||||
assertThat(searchResponse.getHits().hits().length, equalTo(60));
|
||||
for (int i = 0; i < 60; i++) {
|
||||
SearchHit hit = searchResponse.getHits().hits()[i];
|
||||
SearchHit[] hits = searchResponse.getHits().hits();
|
||||
if (hits.length == 0) {
|
||||
break; // finished
|
||||
}
|
||||
for (int i = 0; i < hits.length; ++i) {
|
||||
SearchHit hit = hits[i];
|
||||
assertThat(hit.explanation(), notNullValue());
|
||||
assertThat("id[" + hit.id() + "]", hit.id(), equalTo(Integer.toString(i)));
|
||||
assertThat("id[" + hit.id() + "]", hit.id(), equalTo(Integer.toString(total + i)));
|
||||
}
|
||||
|
||||
searchResponse = client().searchScroll(searchScrollRequest(searchResponse.getScrollId())).actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().totalHits(), equalTo(100l));
|
||||
assertThat(searchResponse.getHits().hits().length, equalTo(40));
|
||||
for (int i = 0; i < 40; i++) {
|
||||
SearchHit hit = searchResponse.getHits().hits()[i];
|
||||
assertThat("id[" + hit.id() + "]", hit.id(), equalTo(Integer.toString(i + 60)));
|
||||
total += hits.length;
|
||||
searchResponse = client().prepareSearchScroll(searchResponse.getScrollId()).setScroll(TimeValue.timeValueSeconds(30)).get();
|
||||
}
|
||||
clearScroll(searchResponse.getScrollId());
|
||||
assertEquals(100, total);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryThenFetch() throws Exception {
|
||||
prepareData();
|
||||
|
||||
SearchSourceBuilder source = searchSource()
|
||||
.query(termQuery("multi", "test"))
|
||||
.sort("nid", SortOrder.DESC) // we have to sort here to have some ordering with dist scoring
|
||||
.from(0).size(60).explain(true);
|
||||
|
||||
SearchResponse searchResponse = client().search(searchRequest("test").source(source).searchType(QUERY_THEN_FETCH).scroll(new Scroll(timeValueMinutes(10)))).actionGet();
|
||||
int total = 0;
|
||||
SearchResponse searchResponse = client().prepareSearch("test").setSearchType(QUERY_THEN_FETCH).setQuery(termQuery("multi", "test")).setSize(60).setExplain(true).addSort("nid", SortOrder.DESC).setScroll(TimeValue.timeValueSeconds(30)).get();
|
||||
while (true) {
|
||||
assertNoFailures(searchResponse);
|
||||
assertThat(searchResponse.getHits().totalHits(), equalTo(100l));
|
||||
assertThat(searchResponse.getHits().hits().length, equalTo(60));
|
||||
for (int i = 0; i < 60; i++) {
|
||||
SearchHit hit = searchResponse.getHits().hits()[i];
|
||||
SearchHit[] hits = searchResponse.getHits().hits();
|
||||
if (hits.length == 0) {
|
||||
break; // finished
|
||||
}
|
||||
for (int i = 0; i < hits.length; ++i) {
|
||||
SearchHit hit = hits[i];
|
||||
assertThat(hit.explanation(), notNullValue());
|
||||
assertThat("id[" + hit.id() + "]", hit.id(), equalTo(Integer.toString(100 - i - 1)));
|
||||
assertThat("id[" + hit.id() + "]", hit.id(), equalTo(Integer.toString(100 - total - i - 1)));
|
||||
}
|
||||
|
||||
searchResponse = client().searchScroll(searchScrollRequest(searchResponse.getScrollId())).actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().totalHits(), equalTo(100l));
|
||||
assertThat(searchResponse.getHits().hits().length, equalTo(40));
|
||||
for (int i = 0; i < 40; i++) {
|
||||
SearchHit hit = searchResponse.getHits().hits()[i];
|
||||
assertThat("id[" + hit.id() + "]", hit.id(), equalTo(Integer.toString(100 - 60 - 1 - i)));
|
||||
total += hits.length;
|
||||
searchResponse = client().prepareSearchScroll(searchResponse.getScrollId()).setScroll(TimeValue.timeValueSeconds(30)).get();
|
||||
}
|
||||
clearScroll(searchResponse.getScrollId());
|
||||
assertEquals(100, total);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -2194,7 +2194,7 @@ public class SimpleChildQuerySearchTests extends ElasticsearchIntegrationTest {
|
|||
assertHitCount(searchResponse, 2l);
|
||||
}
|
||||
|
||||
List<IndexRequestBuilder> createMinMaxDocBuilders() {
|
||||
private List<IndexRequestBuilder> createMinMaxDocBuilders() {
|
||||
List<IndexRequestBuilder> indexBuilders = new ArrayList<>();
|
||||
// Parent 1 and its children
|
||||
indexBuilders.add(client().prepareIndex().setType("parent").setId("1").setIndex("test").setSource("id",1));
|
||||
|
@ -2231,8 +2231,8 @@ public class SimpleChildQuerySearchTests extends ElasticsearchIntegrationTest {
|
|||
return indexBuilders;
|
||||
}
|
||||
|
||||
SearchResponse MinMaxQuery(String scoreType, int minChildren, int maxChildren, int cutoff) throws SearchPhaseExecutionException {
|
||||
SearchResponse response = client()
|
||||
private SearchResponse minMaxQuery(String scoreType, int minChildren, int maxChildren, int cutoff) throws SearchPhaseExecutionException {
|
||||
return client()
|
||||
.prepareSearch("test")
|
||||
.setQuery(
|
||||
QueryBuilders
|
||||
|
@ -2244,25 +2244,22 @@ public class SimpleChildQuerySearchTests extends ElasticsearchIntegrationTest {
|
|||
.add(FilterBuilders.termFilter("foo", "four"), factorFunction(1))).scoreType(scoreType)
|
||||
.minChildren(minChildren).maxChildren(maxChildren).setShortCircuitCutoff(cutoff))
|
||||
.addSort("_score", SortOrder.DESC).addSort("id", SortOrder.ASC).get();
|
||||
assertSearchResponse(response);
|
||||
return response;
|
||||
}
|
||||
|
||||
SearchResponse MinMaxFilter( int minChildren, int maxChildren, int cutoff) throws SearchPhaseExecutionException {
|
||||
SearchResponse response = client()
|
||||
private SearchResponse minMaxFilter(int minChildren, int maxChildren, int cutoff) throws SearchPhaseExecutionException {
|
||||
return client()
|
||||
.prepareSearch("test")
|
||||
.setQuery(
|
||||
QueryBuilders.constantScoreQuery(FilterBuilders.hasChildFilter("child", termFilter("foo", "two"))
|
||||
.minChildren(minChildren).maxChildren(maxChildren).setShortCircuitCutoff(cutoff)))
|
||||
.addSort("id", SortOrder.ASC).setTrackScores(true).get();
|
||||
assertSearchResponse(response);
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testMinMaxChildren() throws Exception {
|
||||
assertAcked(prepareCreate("test").addMapping("parent").addMapping("child", "_parent", "type=parent"));
|
||||
assertAcked(prepareCreate("test")
|
||||
.addMapping("parent", "id", "type=long")
|
||||
.addMapping("child", "_parent", "type=parent"));
|
||||
ensureGreen();
|
||||
|
||||
indexRandom(true, createMinMaxDocBuilders().toArray(new IndexRequestBuilder[0]));
|
||||
|
@ -2270,7 +2267,7 @@ public class SimpleChildQuerySearchTests extends ElasticsearchIntegrationTest {
|
|||
int cutoff = getRandom().nextInt(4);
|
||||
|
||||
// Score mode = NONE
|
||||
response = MinMaxQuery("none", 0, 0, cutoff);
|
||||
response = minMaxQuery("none", 0, 0, cutoff);
|
||||
|
||||
assertThat(response.getHits().totalHits(), equalTo(3l));
|
||||
assertThat(response.getHits().hits()[0].id(), equalTo("2"));
|
||||
|
@ -2280,7 +2277,7 @@ public class SimpleChildQuerySearchTests extends ElasticsearchIntegrationTest {
|
|||
assertThat(response.getHits().hits()[2].id(), equalTo("4"));
|
||||
assertThat(response.getHits().hits()[2].score(), equalTo(1f));
|
||||
|
||||
response = MinMaxQuery("none", 1, 0, cutoff);
|
||||
response = minMaxQuery("none", 1, 0, cutoff);
|
||||
|
||||
assertThat(response.getHits().totalHits(), equalTo(3l));
|
||||
assertThat(response.getHits().hits()[0].id(), equalTo("2"));
|
||||
|
@ -2290,7 +2287,7 @@ public class SimpleChildQuerySearchTests extends ElasticsearchIntegrationTest {
|
|||
assertThat(response.getHits().hits()[2].id(), equalTo("4"));
|
||||
assertThat(response.getHits().hits()[2].score(), equalTo(1f));
|
||||
|
||||
response = MinMaxQuery("none", 2, 0, cutoff);
|
||||
response = minMaxQuery("none", 2, 0, cutoff);
|
||||
|
||||
assertThat(response.getHits().totalHits(), equalTo(2l));
|
||||
assertThat(response.getHits().hits()[0].id(), equalTo("3"));
|
||||
|
@ -2298,17 +2295,17 @@ public class SimpleChildQuerySearchTests extends ElasticsearchIntegrationTest {
|
|||
assertThat(response.getHits().hits()[1].id(), equalTo("4"));
|
||||
assertThat(response.getHits().hits()[1].score(), equalTo(1f));
|
||||
|
||||
response = MinMaxQuery("none", 3, 0, cutoff);
|
||||
response = minMaxQuery("none", 3, 0, cutoff);
|
||||
|
||||
assertThat(response.getHits().totalHits(), equalTo(1l));
|
||||
assertThat(response.getHits().hits()[0].id(), equalTo("4"));
|
||||
assertThat(response.getHits().hits()[0].score(), equalTo(1f));
|
||||
|
||||
response = MinMaxQuery("none", 4, 0, cutoff);
|
||||
response = minMaxQuery("none", 4, 0, cutoff);
|
||||
|
||||
assertThat(response.getHits().totalHits(), equalTo(0l));
|
||||
|
||||
response = MinMaxQuery("none", 0, 4, cutoff);
|
||||
response = minMaxQuery("none", 0, 4, cutoff);
|
||||
|
||||
assertThat(response.getHits().totalHits(), equalTo(3l));
|
||||
assertThat(response.getHits().hits()[0].id(), equalTo("2"));
|
||||
|
@ -2318,7 +2315,7 @@ public class SimpleChildQuerySearchTests extends ElasticsearchIntegrationTest {
|
|||
assertThat(response.getHits().hits()[2].id(), equalTo("4"));
|
||||
assertThat(response.getHits().hits()[2].score(), equalTo(1f));
|
||||
|
||||
response = MinMaxQuery("none", 0, 3, cutoff);
|
||||
response = minMaxQuery("none", 0, 3, cutoff);
|
||||
|
||||
assertThat(response.getHits().totalHits(), equalTo(3l));
|
||||
assertThat(response.getHits().hits()[0].id(), equalTo("2"));
|
||||
|
@ -2328,7 +2325,7 @@ public class SimpleChildQuerySearchTests extends ElasticsearchIntegrationTest {
|
|||
assertThat(response.getHits().hits()[2].id(), equalTo("4"));
|
||||
assertThat(response.getHits().hits()[2].score(), equalTo(1f));
|
||||
|
||||
response = MinMaxQuery("none", 0, 2, cutoff);
|
||||
response = minMaxQuery("none", 0, 2, cutoff);
|
||||
|
||||
assertThat(response.getHits().totalHits(), equalTo(2l));
|
||||
assertThat(response.getHits().hits()[0].id(), equalTo("2"));
|
||||
|
@ -2336,21 +2333,21 @@ public class SimpleChildQuerySearchTests extends ElasticsearchIntegrationTest {
|
|||
assertThat(response.getHits().hits()[1].id(), equalTo("3"));
|
||||
assertThat(response.getHits().hits()[1].score(), equalTo(1f));
|
||||
|
||||
response = MinMaxQuery("none", 2, 2, cutoff);
|
||||
response = minMaxQuery("none", 2, 2, cutoff);
|
||||
|
||||
assertThat(response.getHits().totalHits(), equalTo(1l));
|
||||
assertThat(response.getHits().hits()[0].id(), equalTo("3"));
|
||||
assertThat(response.getHits().hits()[0].score(), equalTo(1f));
|
||||
|
||||
try {
|
||||
response = MinMaxQuery("none", 3, 2, cutoff);
|
||||
response = minMaxQuery("none", 3, 2, cutoff);
|
||||
fail();
|
||||
} catch (SearchPhaseExecutionException e) {
|
||||
assertThat(e.getMessage(), containsString("[has_child] 'max_children' is less than 'min_children'"));
|
||||
}
|
||||
|
||||
// Score mode = SUM
|
||||
response = MinMaxQuery("sum", 0, 0, cutoff);
|
||||
response = minMaxQuery("sum", 0, 0, cutoff);
|
||||
|
||||
assertThat(response.getHits().totalHits(), equalTo(3l));
|
||||
assertThat(response.getHits().hits()[0].id(), equalTo("4"));
|
||||
|
@ -2360,7 +2357,7 @@ public class SimpleChildQuerySearchTests extends ElasticsearchIntegrationTest {
|
|||
assertThat(response.getHits().hits()[2].id(), equalTo("2"));
|
||||
assertThat(response.getHits().hits()[2].score(), equalTo(1f));
|
||||
|
||||
response = MinMaxQuery("sum", 1, 0, cutoff);
|
||||
response = minMaxQuery("sum", 1, 0, cutoff);
|
||||
|
||||
assertThat(response.getHits().totalHits(), equalTo(3l));
|
||||
assertThat(response.getHits().hits()[0].id(), equalTo("4"));
|
||||
|
@ -2370,7 +2367,7 @@ public class SimpleChildQuerySearchTests extends ElasticsearchIntegrationTest {
|
|||
assertThat(response.getHits().hits()[2].id(), equalTo("2"));
|
||||
assertThat(response.getHits().hits()[2].score(), equalTo(1f));
|
||||
|
||||
response = MinMaxQuery("sum", 2, 0, cutoff);
|
||||
response = minMaxQuery("sum", 2, 0, cutoff);
|
||||
|
||||
assertThat(response.getHits().totalHits(), equalTo(2l));
|
||||
assertThat(response.getHits().hits()[0].id(), equalTo("4"));
|
||||
|
@ -2378,17 +2375,17 @@ public class SimpleChildQuerySearchTests extends ElasticsearchIntegrationTest {
|
|||
assertThat(response.getHits().hits()[1].id(), equalTo("3"));
|
||||
assertThat(response.getHits().hits()[1].score(), equalTo(3f));
|
||||
|
||||
response = MinMaxQuery("sum", 3, 0, cutoff);
|
||||
response = minMaxQuery("sum", 3, 0, cutoff);
|
||||
|
||||
assertThat(response.getHits().totalHits(), equalTo(1l));
|
||||
assertThat(response.getHits().hits()[0].id(), equalTo("4"));
|
||||
assertThat(response.getHits().hits()[0].score(), equalTo(6f));
|
||||
|
||||
response = MinMaxQuery("sum", 4, 0, cutoff);
|
||||
response = minMaxQuery("sum", 4, 0, cutoff);
|
||||
|
||||
assertThat(response.getHits().totalHits(), equalTo(0l));
|
||||
|
||||
response = MinMaxQuery("sum", 0, 4, cutoff);
|
||||
response = minMaxQuery("sum", 0, 4, cutoff);
|
||||
|
||||
assertThat(response.getHits().totalHits(), equalTo(3l));
|
||||
assertThat(response.getHits().hits()[0].id(), equalTo("4"));
|
||||
|
@ -2398,7 +2395,7 @@ public class SimpleChildQuerySearchTests extends ElasticsearchIntegrationTest {
|
|||
assertThat(response.getHits().hits()[2].id(), equalTo("2"));
|
||||
assertThat(response.getHits().hits()[2].score(), equalTo(1f));
|
||||
|
||||
response = MinMaxQuery("sum", 0, 3, cutoff);
|
||||
response = minMaxQuery("sum", 0, 3, cutoff);
|
||||
|
||||
assertThat(response.getHits().totalHits(), equalTo(3l));
|
||||
assertThat(response.getHits().hits()[0].id(), equalTo("4"));
|
||||
|
@ -2408,7 +2405,7 @@ public class SimpleChildQuerySearchTests extends ElasticsearchIntegrationTest {
|
|||
assertThat(response.getHits().hits()[2].id(), equalTo("2"));
|
||||
assertThat(response.getHits().hits()[2].score(), equalTo(1f));
|
||||
|
||||
response = MinMaxQuery("sum", 0, 2, cutoff);
|
||||
response = minMaxQuery("sum", 0, 2, cutoff);
|
||||
|
||||
assertThat(response.getHits().totalHits(), equalTo(2l));
|
||||
assertThat(response.getHits().hits()[0].id(), equalTo("3"));
|
||||
|
@ -2416,21 +2413,21 @@ public class SimpleChildQuerySearchTests extends ElasticsearchIntegrationTest {
|
|||
assertThat(response.getHits().hits()[1].id(), equalTo("2"));
|
||||
assertThat(response.getHits().hits()[1].score(), equalTo(1f));
|
||||
|
||||
response = MinMaxQuery("sum", 2, 2, cutoff);
|
||||
response = minMaxQuery("sum", 2, 2, cutoff);
|
||||
|
||||
assertThat(response.getHits().totalHits(), equalTo(1l));
|
||||
assertThat(response.getHits().hits()[0].id(), equalTo("3"));
|
||||
assertThat(response.getHits().hits()[0].score(), equalTo(3f));
|
||||
|
||||
try {
|
||||
response = MinMaxQuery("sum", 3, 2, cutoff);
|
||||
response = minMaxQuery("sum", 3, 2, cutoff);
|
||||
fail();
|
||||
} catch (SearchPhaseExecutionException e) {
|
||||
assertThat(e.getMessage(), containsString("[has_child] 'max_children' is less than 'min_children'"));
|
||||
}
|
||||
|
||||
// Score mode = MAX
|
||||
response = MinMaxQuery("max", 0, 0, cutoff);
|
||||
response = minMaxQuery("max", 0, 0, cutoff);
|
||||
|
||||
assertThat(response.getHits().totalHits(), equalTo(3l));
|
||||
assertThat(response.getHits().hits()[0].id(), equalTo("4"));
|
||||
|
@ -2440,7 +2437,7 @@ public class SimpleChildQuerySearchTests extends ElasticsearchIntegrationTest {
|
|||
assertThat(response.getHits().hits()[2].id(), equalTo("2"));
|
||||
assertThat(response.getHits().hits()[2].score(), equalTo(1f));
|
||||
|
||||
response = MinMaxQuery("max", 1, 0, cutoff);
|
||||
response = minMaxQuery("max", 1, 0, cutoff);
|
||||
|
||||
assertThat(response.getHits().totalHits(), equalTo(3l));
|
||||
assertThat(response.getHits().hits()[0].id(), equalTo("4"));
|
||||
|
@ -2450,7 +2447,7 @@ public class SimpleChildQuerySearchTests extends ElasticsearchIntegrationTest {
|
|||
assertThat(response.getHits().hits()[2].id(), equalTo("2"));
|
||||
assertThat(response.getHits().hits()[2].score(), equalTo(1f));
|
||||
|
||||
response = MinMaxQuery("max", 2, 0, cutoff);
|
||||
response = minMaxQuery("max", 2, 0, cutoff);
|
||||
|
||||
assertThat(response.getHits().totalHits(), equalTo(2l));
|
||||
assertThat(response.getHits().hits()[0].id(), equalTo("4"));
|
||||
|
@ -2458,17 +2455,17 @@ public class SimpleChildQuerySearchTests extends ElasticsearchIntegrationTest {
|
|||
assertThat(response.getHits().hits()[1].id(), equalTo("3"));
|
||||
assertThat(response.getHits().hits()[1].score(), equalTo(2f));
|
||||
|
||||
response = MinMaxQuery("max", 3, 0, cutoff);
|
||||
response = minMaxQuery("max", 3, 0, cutoff);
|
||||
|
||||
assertThat(response.getHits().totalHits(), equalTo(1l));
|
||||
assertThat(response.getHits().hits()[0].id(), equalTo("4"));
|
||||
assertThat(response.getHits().hits()[0].score(), equalTo(3f));
|
||||
|
||||
response = MinMaxQuery("max", 4, 0, cutoff);
|
||||
response = minMaxQuery("max", 4, 0, cutoff);
|
||||
|
||||
assertThat(response.getHits().totalHits(), equalTo(0l));
|
||||
|
||||
response = MinMaxQuery("max", 0, 4, cutoff);
|
||||
response = minMaxQuery("max", 0, 4, cutoff);
|
||||
|
||||
assertThat(response.getHits().totalHits(), equalTo(3l));
|
||||
assertThat(response.getHits().hits()[0].id(), equalTo("4"));
|
||||
|
@ -2478,7 +2475,7 @@ public class SimpleChildQuerySearchTests extends ElasticsearchIntegrationTest {
|
|||
assertThat(response.getHits().hits()[2].id(), equalTo("2"));
|
||||
assertThat(response.getHits().hits()[2].score(), equalTo(1f));
|
||||
|
||||
response = MinMaxQuery("max", 0, 3, cutoff);
|
||||
response = minMaxQuery("max", 0, 3, cutoff);
|
||||
|
||||
assertThat(response.getHits().totalHits(), equalTo(3l));
|
||||
assertThat(response.getHits().hits()[0].id(), equalTo("4"));
|
||||
|
@ -2488,7 +2485,7 @@ public class SimpleChildQuerySearchTests extends ElasticsearchIntegrationTest {
|
|||
assertThat(response.getHits().hits()[2].id(), equalTo("2"));
|
||||
assertThat(response.getHits().hits()[2].score(), equalTo(1f));
|
||||
|
||||
response = MinMaxQuery("max", 0, 2, cutoff);
|
||||
response = minMaxQuery("max", 0, 2, cutoff);
|
||||
|
||||
assertThat(response.getHits().totalHits(), equalTo(2l));
|
||||
assertThat(response.getHits().hits()[0].id(), equalTo("3"));
|
||||
|
@ -2496,21 +2493,21 @@ public class SimpleChildQuerySearchTests extends ElasticsearchIntegrationTest {
|
|||
assertThat(response.getHits().hits()[1].id(), equalTo("2"));
|
||||
assertThat(response.getHits().hits()[1].score(), equalTo(1f));
|
||||
|
||||
response = MinMaxQuery("max", 2, 2, cutoff);
|
||||
response = minMaxQuery("max", 2, 2, cutoff);
|
||||
|
||||
assertThat(response.getHits().totalHits(), equalTo(1l));
|
||||
assertThat(response.getHits().hits()[0].id(), equalTo("3"));
|
||||
assertThat(response.getHits().hits()[0].score(), equalTo(2f));
|
||||
|
||||
try {
|
||||
response = MinMaxQuery("max", 3, 2, cutoff);
|
||||
response = minMaxQuery("max", 3, 2, cutoff);
|
||||
fail();
|
||||
} catch (SearchPhaseExecutionException e) {
|
||||
assertThat(e.getMessage(), containsString("[has_child] 'max_children' is less than 'min_children'"));
|
||||
}
|
||||
|
||||
// Score mode = AVG
|
||||
response = MinMaxQuery("avg", 0, 0, cutoff);
|
||||
response = minMaxQuery("avg", 0, 0, cutoff);
|
||||
|
||||
assertThat(response.getHits().totalHits(), equalTo(3l));
|
||||
assertThat(response.getHits().hits()[0].id(), equalTo("4"));
|
||||
|
@ -2520,7 +2517,7 @@ public class SimpleChildQuerySearchTests extends ElasticsearchIntegrationTest {
|
|||
assertThat(response.getHits().hits()[2].id(), equalTo("2"));
|
||||
assertThat(response.getHits().hits()[2].score(), equalTo(1f));
|
||||
|
||||
response = MinMaxQuery("avg", 1, 0, cutoff);
|
||||
response = minMaxQuery("avg", 1, 0, cutoff);
|
||||
|
||||
assertThat(response.getHits().totalHits(), equalTo(3l));
|
||||
assertThat(response.getHits().hits()[0].id(), equalTo("4"));
|
||||
|
@ -2530,7 +2527,7 @@ public class SimpleChildQuerySearchTests extends ElasticsearchIntegrationTest {
|
|||
assertThat(response.getHits().hits()[2].id(), equalTo("2"));
|
||||
assertThat(response.getHits().hits()[2].score(), equalTo(1f));
|
||||
|
||||
response = MinMaxQuery("avg", 2, 0, cutoff);
|
||||
response = minMaxQuery("avg", 2, 0, cutoff);
|
||||
|
||||
assertThat(response.getHits().totalHits(), equalTo(2l));
|
||||
assertThat(response.getHits().hits()[0].id(), equalTo("4"));
|
||||
|
@ -2538,17 +2535,17 @@ public class SimpleChildQuerySearchTests extends ElasticsearchIntegrationTest {
|
|||
assertThat(response.getHits().hits()[1].id(), equalTo("3"));
|
||||
assertThat(response.getHits().hits()[1].score(), equalTo(1.5f));
|
||||
|
||||
response = MinMaxQuery("avg", 3, 0, cutoff);
|
||||
response = minMaxQuery("avg", 3, 0, cutoff);
|
||||
|
||||
assertThat(response.getHits().totalHits(), equalTo(1l));
|
||||
assertThat(response.getHits().hits()[0].id(), equalTo("4"));
|
||||
assertThat(response.getHits().hits()[0].score(), equalTo(2f));
|
||||
|
||||
response = MinMaxQuery("avg", 4, 0, cutoff);
|
||||
response = minMaxQuery("avg", 4, 0, cutoff);
|
||||
|
||||
assertThat(response.getHits().totalHits(), equalTo(0l));
|
||||
|
||||
response = MinMaxQuery("avg", 0, 4, cutoff);
|
||||
response = minMaxQuery("avg", 0, 4, cutoff);
|
||||
|
||||
assertThat(response.getHits().totalHits(), equalTo(3l));
|
||||
assertThat(response.getHits().hits()[0].id(), equalTo("4"));
|
||||
|
@ -2558,7 +2555,7 @@ public class SimpleChildQuerySearchTests extends ElasticsearchIntegrationTest {
|
|||
assertThat(response.getHits().hits()[2].id(), equalTo("2"));
|
||||
assertThat(response.getHits().hits()[2].score(), equalTo(1f));
|
||||
|
||||
response = MinMaxQuery("avg", 0, 3, cutoff);
|
||||
response = minMaxQuery("avg", 0, 3, cutoff);
|
||||
|
||||
assertThat(response.getHits().totalHits(), equalTo(3l));
|
||||
assertThat(response.getHits().hits()[0].id(), equalTo("4"));
|
||||
|
@ -2568,7 +2565,7 @@ public class SimpleChildQuerySearchTests extends ElasticsearchIntegrationTest {
|
|||
assertThat(response.getHits().hits()[2].id(), equalTo("2"));
|
||||
assertThat(response.getHits().hits()[2].score(), equalTo(1f));
|
||||
|
||||
response = MinMaxQuery("avg", 0, 2, cutoff);
|
||||
response = minMaxQuery("avg", 0, 2, cutoff);
|
||||
|
||||
assertThat(response.getHits().totalHits(), equalTo(2l));
|
||||
assertThat(response.getHits().hits()[0].id(), equalTo("3"));
|
||||
|
@ -2576,21 +2573,21 @@ public class SimpleChildQuerySearchTests extends ElasticsearchIntegrationTest {
|
|||
assertThat(response.getHits().hits()[1].id(), equalTo("2"));
|
||||
assertThat(response.getHits().hits()[1].score(), equalTo(1f));
|
||||
|
||||
response = MinMaxQuery("avg", 2, 2, cutoff);
|
||||
response = minMaxQuery("avg", 2, 2, cutoff);
|
||||
|
||||
assertThat(response.getHits().totalHits(), equalTo(1l));
|
||||
assertThat(response.getHits().hits()[0].id(), equalTo("3"));
|
||||
assertThat(response.getHits().hits()[0].score(), equalTo(1.5f));
|
||||
|
||||
try {
|
||||
response = MinMaxQuery("avg", 3, 2, cutoff);
|
||||
response = minMaxQuery("avg", 3, 2, cutoff);
|
||||
fail();
|
||||
} catch (SearchPhaseExecutionException e) {
|
||||
assertThat(e.getMessage(), containsString("[has_child] 'max_children' is less than 'min_children'"));
|
||||
}
|
||||
|
||||
// HasChildFilter
|
||||
response = MinMaxFilter(0, 0, cutoff);
|
||||
response = minMaxFilter(0, 0, cutoff);
|
||||
|
||||
assertThat(response.getHits().totalHits(), equalTo(3l));
|
||||
assertThat(response.getHits().hits()[0].id(), equalTo("2"));
|
||||
|
@ -2600,7 +2597,7 @@ public class SimpleChildQuerySearchTests extends ElasticsearchIntegrationTest {
|
|||
assertThat(response.getHits().hits()[2].id(), equalTo("4"));
|
||||
assertThat(response.getHits().hits()[2].score(), equalTo(1f));
|
||||
|
||||
response = MinMaxFilter(1, 0, cutoff);
|
||||
response = minMaxFilter(1, 0, cutoff);
|
||||
|
||||
assertThat(response.getHits().totalHits(), equalTo(3l));
|
||||
assertThat(response.getHits().hits()[0].id(), equalTo("2"));
|
||||
|
@ -2610,7 +2607,7 @@ public class SimpleChildQuerySearchTests extends ElasticsearchIntegrationTest {
|
|||
assertThat(response.getHits().hits()[2].id(), equalTo("4"));
|
||||
assertThat(response.getHits().hits()[2].score(), equalTo(1f));
|
||||
|
||||
response = MinMaxFilter(2, 0, cutoff);
|
||||
response = minMaxFilter(2, 0, cutoff);
|
||||
|
||||
assertThat(response.getHits().totalHits(), equalTo(2l));
|
||||
assertThat(response.getHits().hits()[0].id(), equalTo("3"));
|
||||
|
@ -2618,17 +2615,17 @@ public class SimpleChildQuerySearchTests extends ElasticsearchIntegrationTest {
|
|||
assertThat(response.getHits().hits()[1].id(), equalTo("4"));
|
||||
assertThat(response.getHits().hits()[1].score(), equalTo(1f));
|
||||
|
||||
response = MinMaxFilter(3, 0, cutoff);
|
||||
response = minMaxFilter(3, 0, cutoff);
|
||||
|
||||
assertThat(response.getHits().totalHits(), equalTo(1l));
|
||||
assertThat(response.getHits().hits()[0].id(), equalTo("4"));
|
||||
assertThat(response.getHits().hits()[0].score(), equalTo(1f));
|
||||
|
||||
response = MinMaxFilter(4, 0, cutoff);
|
||||
response = minMaxFilter(4, 0, cutoff);
|
||||
|
||||
assertThat(response.getHits().totalHits(), equalTo(0l));
|
||||
|
||||
response = MinMaxFilter(0, 4, cutoff);
|
||||
response = minMaxFilter(0, 4, cutoff);
|
||||
|
||||
assertThat(response.getHits().totalHits(), equalTo(3l));
|
||||
assertThat(response.getHits().hits()[0].id(), equalTo("2"));
|
||||
|
@ -2638,7 +2635,7 @@ public class SimpleChildQuerySearchTests extends ElasticsearchIntegrationTest {
|
|||
assertThat(response.getHits().hits()[2].id(), equalTo("4"));
|
||||
assertThat(response.getHits().hits()[2].score(), equalTo(1f));
|
||||
|
||||
response = MinMaxFilter(0, 3, cutoff);
|
||||
response = minMaxFilter(0, 3, cutoff);
|
||||
|
||||
assertThat(response.getHits().totalHits(), equalTo(3l));
|
||||
assertThat(response.getHits().hits()[0].id(), equalTo("2"));
|
||||
|
@ -2648,7 +2645,7 @@ public class SimpleChildQuerySearchTests extends ElasticsearchIntegrationTest {
|
|||
assertThat(response.getHits().hits()[2].id(), equalTo("4"));
|
||||
assertThat(response.getHits().hits()[2].score(), equalTo(1f));
|
||||
|
||||
response = MinMaxFilter(0, 2, cutoff);
|
||||
response = minMaxFilter(0, 2, cutoff);
|
||||
|
||||
assertThat(response.getHits().totalHits(), equalTo(2l));
|
||||
assertThat(response.getHits().hits()[0].id(), equalTo("2"));
|
||||
|
@ -2656,14 +2653,14 @@ public class SimpleChildQuerySearchTests extends ElasticsearchIntegrationTest {
|
|||
assertThat(response.getHits().hits()[1].id(), equalTo("3"));
|
||||
assertThat(response.getHits().hits()[1].score(), equalTo(1f));
|
||||
|
||||
response = MinMaxFilter(2, 2, cutoff);
|
||||
response = minMaxFilter(2, 2, cutoff);
|
||||
|
||||
assertThat(response.getHits().totalHits(), equalTo(1l));
|
||||
assertThat(response.getHits().hits()[0].id(), equalTo("3"));
|
||||
assertThat(response.getHits().hits()[0].score(), equalTo(1f));
|
||||
|
||||
try {
|
||||
response = MinMaxFilter(3, 2, cutoff);
|
||||
response = minMaxFilter(3, 2, cutoff);
|
||||
fail();
|
||||
} catch (SearchPhaseExecutionException e) {
|
||||
assertThat(e.getMessage(), containsString("[has_child] 'max_children' is less than 'min_children'"));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue