Fix ExistsQueryBuilder#testToQuery failure (#56006)
Ocassionally this test can fail when the randomized index.version.created is before 6.1. In this case we don't check that if mappedFields.size() == 0 we expect a MatchNoDocsQuery query being returned, which we do for other versions. This fails only occasionally but with the seed provided on the original issue. It also shouldn't be an issue on master since we shouldn't test with these pre-7 index versions there. Closes #55950
This commit is contained in:
parent
d3bcef2962
commit
c2afbf20de
|
@ -63,6 +63,10 @@ public class ExistsQueryBuilderTests extends AbstractQueryTestCase<ExistsQueryBu
|
|||
Collection<String> fields = context.simpleMatchToIndexNames(fieldPattern);
|
||||
Collection<String> mappedFields = fields.stream().filter((field) -> context.getObjectMapper(field) != null
|
||||
|| context.getMapperService().fieldType(field) != null).collect(Collectors.toList());
|
||||
if (mappedFields.size() == 0) {
|
||||
assertThat(query, instanceOf(MatchNoDocsQuery.class));
|
||||
return;
|
||||
}
|
||||
if (context.getIndexSettings().getIndexVersionCreated().before(Version.V_6_1_0)) {
|
||||
if (fields.size() == 1) {
|
||||
assertThat(query, instanceOf(ConstantScoreQuery.class));
|
||||
|
@ -82,9 +86,6 @@ public class ExistsQueryBuilderTests extends AbstractQueryTestCase<ExistsQueryBu
|
|||
assertThat(booleanClause.getOccur(), equalTo(BooleanClause.Occur.SHOULD));
|
||||
}
|
||||
}
|
||||
} else if (mappedFields.size() == 0) {
|
||||
assertThat(query, instanceOf(MatchNoDocsQuery.class));
|
||||
MatchNoDocsQuery matchNoDocsQuery = (MatchNoDocsQuery) query;
|
||||
} else if (fields.size() == 1) {
|
||||
assertThat(query, instanceOf(ConstantScoreQuery.class));
|
||||
ConstantScoreQuery constantScoreQuery = (ConstantScoreQuery) query;
|
||||
|
|
Loading…
Reference in New Issue