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.allowUnmappedFields = indexSettings.isDefaultAllowUnmappedFields();
|
||||||
this.indicesQueriesRegistry = indicesQueriesRegistry;
|
this.indicesQueriesRegistry = indicesQueriesRegistry;
|
||||||
this.percolatorQueryCache = percolatorQueryCache;
|
this.percolatorQueryCache = percolatorQueryCache;
|
||||||
|
this.nestedScope = new NestedScope();
|
||||||
}
|
}
|
||||||
|
|
||||||
public QueryShardContext(QueryShardContext source) {
|
public QueryShardContext(QueryShardContext source) {
|
||||||
|
@ -113,6 +114,7 @@ public class QueryShardContext extends QueryRewriteContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public QueryShardContext clone() {
|
public QueryShardContext clone() {
|
||||||
return new QueryShardContext(indexSettings, bitsetFilterCache, indexFieldDataService, mapperService, similarityService, scriptService, indicesQueriesRegistry, percolatorQueryCache);
|
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;
|
Query innerDocumentsQuery;
|
||||||
if (nestedFilter != null) {
|
if (nestedFilter != null) {
|
||||||
innerDocumentsQuery = nestedFilter.toFilter(context);
|
context.nestedScope().nextLevel(nestedObjectMapper);
|
||||||
|
innerDocumentsQuery = QueryBuilder.rewriteQuery(nestedFilter, context).toFilter(context);
|
||||||
|
context.nestedScope().previousLevel();
|
||||||
} else {
|
} else {
|
||||||
innerDocumentsQuery = nestedObjectMapper.nestedTypeFilter();
|
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,
|
return new QueryShardContext(idxSettings, bitsetFilterCache, ifds, null, null, scriptService,
|
||||||
indicesQueriesRegistry) {
|
indicesQueriesRegistry, null) {
|
||||||
@Override
|
@Override
|
||||||
public MappedFieldType fieldMapper(String name) {
|
public MappedFieldType fieldMapper(String name) {
|
||||||
return provideMappedFieldType(name);
|
return provideMappedFieldType(name);
|
||||||
|
|
Loading…
Reference in New Issue