Removed old 1.x parent/child logic that should have been removed.

`0` really means, don't match any child docs.
This commit is contained in:
Martijn van Groningen 2016-03-17 17:31:39 +01:00
parent 1dd2be81c3
commit 3b17ddcd46
3 changed files with 26 additions and 31 deletions

View File

@ -257,12 +257,7 @@ public class HasChildQueryBuilder extends AbstractQueryBuilder<HasChildQueryBuil
innerQuery = Queries.filtered(innerQuery, childDocMapper.typeFilter());
final ParentChildIndexFieldData parentChildIndexFieldData = context.getForField(parentFieldMapper.fieldType());
int maxChildren = maxChildren();
// 0 in pre 2.x p/c impl means unbounded
if (maxChildren == 0) {
maxChildren = Integer.MAX_VALUE;
}
return new LateParsingQuery(parentDocMapper.typeFilter(), innerQuery, minChildren(), maxChildren,
return new LateParsingQuery(parentDocMapper.typeFilter(), innerQuery, minChildren(), maxChildren(),
parentType, scoreMode, parentChildIndexFieldData, context.getSearchSimilarity());
}

View File

@ -1561,7 +1561,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
SearchResponse response;
// Score mode = NONE
response = minMaxQuery(ScoreMode.None, 0, 0);
response = minMaxQuery(ScoreMode.None, 0, null);
assertThat(response.getHits().totalHits(), equalTo(3L));
assertThat(response.getHits().hits()[0].id(), equalTo("2"));
@ -1571,7 +1571,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
assertThat(response.getHits().hits()[2].id(), equalTo("4"));
assertThat(response.getHits().hits()[2].score(), equalTo(1f));
response = minMaxQuery(ScoreMode.None, 1, 0);
response = minMaxQuery(ScoreMode.None, 1, null);
assertThat(response.getHits().totalHits(), equalTo(3L));
assertThat(response.getHits().hits()[0].id(), equalTo("2"));
@ -1581,7 +1581,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
assertThat(response.getHits().hits()[2].id(), equalTo("4"));
assertThat(response.getHits().hits()[2].score(), equalTo(1f));
response = minMaxQuery(ScoreMode.None, 2, 0);
response = minMaxQuery(ScoreMode.None, 2, null);
assertThat(response.getHits().totalHits(), equalTo(2L));
assertThat(response.getHits().hits()[0].id(), equalTo("3"));
@ -1589,13 +1589,13 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
assertThat(response.getHits().hits()[1].id(), equalTo("4"));
assertThat(response.getHits().hits()[1].score(), equalTo(1f));
response = minMaxQuery(ScoreMode.None, 3, 0);
response = minMaxQuery(ScoreMode.None, 3, null);
assertThat(response.getHits().totalHits(), equalTo(1L));
assertThat(response.getHits().hits()[0].id(), equalTo("4"));
assertThat(response.getHits().hits()[0].score(), equalTo(1f));
response = minMaxQuery(ScoreMode.None, 4, 0);
response = minMaxQuery(ScoreMode.None, 4, null);
assertThat(response.getHits().totalHits(), equalTo(0L));
@ -1641,7 +1641,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
}
// Score mode = SUM
response = minMaxQuery(ScoreMode.Total, 0, 0);
response = minMaxQuery(ScoreMode.Total, 0, null);
assertThat(response.getHits().totalHits(), equalTo(3L));
assertThat(response.getHits().hits()[0].id(), equalTo("4"));
@ -1651,7 +1651,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
assertThat(response.getHits().hits()[2].id(), equalTo("2"));
assertThat(response.getHits().hits()[2].score(), equalTo(1f));
response = minMaxQuery(ScoreMode.Total, 1, 0);
response = minMaxQuery(ScoreMode.Total, 1, null);
assertThat(response.getHits().totalHits(), equalTo(3L));
assertThat(response.getHits().hits()[0].id(), equalTo("4"));
@ -1661,7 +1661,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
assertThat(response.getHits().hits()[2].id(), equalTo("2"));
assertThat(response.getHits().hits()[2].score(), equalTo(1f));
response = minMaxQuery(ScoreMode.Total, 2, 0);
response = minMaxQuery(ScoreMode.Total, 2, null);
assertThat(response.getHits().totalHits(), equalTo(2L));
assertThat(response.getHits().hits()[0].id(), equalTo("4"));
@ -1669,13 +1669,13 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
assertThat(response.getHits().hits()[1].id(), equalTo("3"));
assertThat(response.getHits().hits()[1].score(), equalTo(3f));
response = minMaxQuery(ScoreMode.Total, 3, 0);
response = minMaxQuery(ScoreMode.Total, 3, null);
assertThat(response.getHits().totalHits(), equalTo(1L));
assertThat(response.getHits().hits()[0].id(), equalTo("4"));
assertThat(response.getHits().hits()[0].score(), equalTo(6f));
response = minMaxQuery(ScoreMode.Total, 4, 0);
response = minMaxQuery(ScoreMode.Total, 4, null);
assertThat(response.getHits().totalHits(), equalTo(0L));
@ -1721,7 +1721,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
}
// Score mode = MAX
response = minMaxQuery(ScoreMode.Max, 0, 0);
response = minMaxQuery(ScoreMode.Max, 0, null);
assertThat(response.getHits().totalHits(), equalTo(3L));
assertThat(response.getHits().hits()[0].id(), equalTo("4"));
@ -1731,7 +1731,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
assertThat(response.getHits().hits()[2].id(), equalTo("2"));
assertThat(response.getHits().hits()[2].score(), equalTo(1f));
response = minMaxQuery(ScoreMode.Max, 1, 0);
response = minMaxQuery(ScoreMode.Max, 1, null);
assertThat(response.getHits().totalHits(), equalTo(3L));
assertThat(response.getHits().hits()[0].id(), equalTo("4"));
@ -1741,7 +1741,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
assertThat(response.getHits().hits()[2].id(), equalTo("2"));
assertThat(response.getHits().hits()[2].score(), equalTo(1f));
response = minMaxQuery(ScoreMode.Max, 2, 0);
response = minMaxQuery(ScoreMode.Max, 2, null);
assertThat(response.getHits().totalHits(), equalTo(2L));
assertThat(response.getHits().hits()[0].id(), equalTo("4"));
@ -1749,13 +1749,13 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
assertThat(response.getHits().hits()[1].id(), equalTo("3"));
assertThat(response.getHits().hits()[1].score(), equalTo(2f));
response = minMaxQuery(ScoreMode.Max, 3, 0);
response = minMaxQuery(ScoreMode.Max, 3, null);
assertThat(response.getHits().totalHits(), equalTo(1L));
assertThat(response.getHits().hits()[0].id(), equalTo("4"));
assertThat(response.getHits().hits()[0].score(), equalTo(3f));
response = minMaxQuery(ScoreMode.Max, 4, 0);
response = minMaxQuery(ScoreMode.Max, 4, null);
assertThat(response.getHits().totalHits(), equalTo(0L));
@ -1801,7 +1801,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
}
// Score mode = AVG
response = minMaxQuery(ScoreMode.Avg, 0, 0);
response = minMaxQuery(ScoreMode.Avg, 0, null);
assertThat(response.getHits().totalHits(), equalTo(3L));
assertThat(response.getHits().hits()[0].id(), equalTo("4"));
@ -1811,7 +1811,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
assertThat(response.getHits().hits()[2].id(), equalTo("2"));
assertThat(response.getHits().hits()[2].score(), equalTo(1f));
response = minMaxQuery(ScoreMode.Avg, 1, 0);
response = minMaxQuery(ScoreMode.Avg, 1, null);
assertThat(response.getHits().totalHits(), equalTo(3L));
assertThat(response.getHits().hits()[0].id(), equalTo("4"));
@ -1821,7 +1821,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
assertThat(response.getHits().hits()[2].id(), equalTo("2"));
assertThat(response.getHits().hits()[2].score(), equalTo(1f));
response = minMaxQuery(ScoreMode.Avg, 2, 0);
response = minMaxQuery(ScoreMode.Avg, 2, null);
assertThat(response.getHits().totalHits(), equalTo(2L));
assertThat(response.getHits().hits()[0].id(), equalTo("4"));
@ -1829,13 +1829,13 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
assertThat(response.getHits().hits()[1].id(), equalTo("3"));
assertThat(response.getHits().hits()[1].score(), equalTo(1.5f));
response = minMaxQuery(ScoreMode.Avg, 3, 0);
response = minMaxQuery(ScoreMode.Avg, 3, null);
assertThat(response.getHits().totalHits(), equalTo(1L));
assertThat(response.getHits().hits()[0].id(), equalTo("4"));
assertThat(response.getHits().hits()[0].score(), equalTo(2f));
response = minMaxQuery(ScoreMode.Avg, 4, 0);
response = minMaxQuery(ScoreMode.Avg, 4, null);
assertThat(response.getHits().totalHits(), equalTo(0L));

View File

@ -116,11 +116,11 @@ in favour of `query` and `no_match_query`.
* The `score_type` parameter to the `nested`, has_child` and `has_parent` queries has been removed in favour of `score_mode`.
Also, the `total` score mode has been removed in favour of the `sum` mode.
* When the `max_children` parameter was set to `0` on the `has_child` query
then there was no upper limit on how many child documents were allowed to
match. Now, `0` really means that zero child documents are allowed. If no
upper limit is needed then the `max_children` parameter shouldn't be specified
at all.
* When the `max_children` parameter was set to `0` on the `has_child` query
then there was no upper limit on how many child documents were allowed to
match. Now, `0` really means that zero child documents are allowed. If no
upper limit is needed then the `max_children` parameter shouldn't be specified
at all.
==== Top level `filter` parameter