Skip to content

Commit

Permalink
Make sure to use nestedScope levels when building nested filters
Browse files Browse the repository at this point in the history
  • Loading branch information
cbuescher committed Mar 22, 2016
1 parent 25da6b2 commit 697174d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public QueryShardContext(IndexSettings indexSettings, BitsetFilterCache bitsetFi
this.allowUnmappedFields = indexSettings.isDefaultAllowUnmappedFields();
this.indicesQueriesRegistry = indicesQueriesRegistry;
this.percolatorQueryCache = percolatorQueryCache;
this.nestedScope = new NestedScope();
}

public QueryShardContext(QueryShardContext source) {
Expand All @@ -113,6 +114,7 @@ public QueryShardContext(QueryShardContext source) {
}


@Override
public QueryShardContext clone() {
return new QueryShardContext(indexSettings, bitsetFilterCache, indexFieldDataService, mapperService, similarityService, scriptService, indicesQueriesRegistry, percolatorQueryCache);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ protected static Nested resolveNested(QueryShardContext context, String nestedPa
}
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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ public void onCache(ShardId shardId, Accountable accountable) {
}
});
return new QueryShardContext(idxSettings, bitsetFilterCache, ifds, null, null, scriptService,
indicesQueriesRegistry) {
indicesQueriesRegistry, null) {
@Override
public MappedFieldType fieldMapper(String name) {
return provideMappedFieldType(name);
Expand Down

0 comments on commit 697174d

Please sign in to comment.