Skip to content

Commit 899394d

Browse files
authored
Don't use TypeField for nested filters (#44482)
We changed things in #27469 to filter parent docs by using an exists query on the primary_term field. However, the equivalent query for nested documents is still using the type field. This commit makes newNestedFilter build the complement of newNonNestedFilter instead.
1 parent 94962b3 commit 899394d

File tree

1 file changed

+1
-5
lines changed
  • server/src/main/java/org/elasticsearch/common/lucene/search

1 file changed

+1
-5
lines changed

server/src/main/java/org/elasticsearch/common/lucene/search/Queries.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,16 @@
1919

2020
package org.elasticsearch.common.lucene.search;
2121

22-
import org.apache.lucene.index.Term;
2322
import org.apache.lucene.search.BooleanClause;
2423
import org.apache.lucene.search.BooleanClause.Occur;
2524
import org.apache.lucene.search.BooleanQuery;
2625
import org.apache.lucene.search.DocValuesFieldExistsQuery;
2726
import org.apache.lucene.search.MatchAllDocsQuery;
2827
import org.apache.lucene.search.MatchNoDocsQuery;
29-
import org.apache.lucene.search.PrefixQuery;
3028
import org.apache.lucene.search.Query;
31-
import org.apache.lucene.util.BytesRef;
3229
import org.elasticsearch.ElasticsearchException;
3330
import org.elasticsearch.common.Nullable;
3431
import org.elasticsearch.index.mapper.SeqNoFieldMapper;
35-
import org.elasticsearch.index.mapper.TypeFieldMapper;
3632

3733
import java.util.Collection;
3834
import java.util.Collections;
@@ -65,7 +61,7 @@ public static Query newLenientFieldQuery(String field, RuntimeException e) {
6561
}
6662

6763
public static Query newNestedFilter() {
68-
return new PrefixQuery(new Term(TypeFieldMapper.NAME, new BytesRef("__")));
64+
return not(newNonNestedFilter());
6965
}
7066

7167
/**

0 commit comments

Comments
 (0)