Make sure to use nestedScope levels when building nested filters
This commit is contained in:
parent
25da6b2f2e
commit
697174dcb0
|
@ -105,6 +105,7 @@ public class QueryShardContext extends QueryRewriteContext {
|
|||
this.allowUnmappedFields = indexSettings.isDefaultAllowUnmappedFields();
|
||||
this.indicesQueriesRegistry = indicesQueriesRegistry;
|
||||
this.percolatorQueryCache = percolatorQueryCache;
|
||||
this.nestedScope = new NestedScope();
|
||||
}
|
||||
|
||||
public QueryShardContext(QueryShardContext source) {
|
||||
|
@ -113,6 +114,7 @@ public class QueryShardContext extends QueryRewriteContext {
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public QueryShardContext clone() {
|
||||
return new QueryShardContext(indexSettings, bitsetFilterCache, indexFieldDataService, mapperService, similarityService, scriptService, indicesQueriesRegistry, percolatorQueryCache);
|
||||
}
|
||||
|
|
|
@ -54,7 +54,9 @@ public abstract class SortBuilder<T extends SortBuilder<?>> implements ToXConten
|
|||
}
|
||||
Query innerDocumentsQuery;
|
||||
if (nestedFilter != null) {
|
||||
innerDocumentsQuery = nestedFilter.toFilter(context);
|
||||
context.nestedScope().nextLevel(nestedObjectMapper);
|
||||
innerDocumentsQuery = QueryBuilder.rewriteQuery(nestedFilter, context).toFilter(context);
|
||||
context.nestedScope().previousLevel();
|
||||
} else {
|
||||
innerDocumentsQuery = nestedObjectMapper.nestedTypeFilter();
|
||||
}
|
||||
|
|
|
@ -242,7 +242,7 @@ public abstract class AbstractSortTestCase<T extends SortBuilder<T> & SortBuilde
|
|||
}
|
||||
});
|
||||
return new QueryShardContext(idxSettings, bitsetFilterCache, ifds, null, null, scriptService,
|
||||
indicesQueriesRegistry) {
|
||||
indicesQueriesRegistry, null) {
|
||||
@Override
|
||||
public MappedFieldType fieldMapper(String name) {
|
||||
return provideMappedFieldType(name);
|
||||
|
|
Loading…
Reference in New Issue