use of org.elasticsearch.index.query.support.NestedScope in project elasticsearch by elastic.
the class QueryShardContext method reset.
private void reset() {
allowUnmappedFields = indexSettings.isDefaultAllowUnmappedFields();
this.lookup = null;
this.namedQueries.clear();
this.nestedScope = new NestedScope();
this.isFilter = false;
}
use of org.elasticsearch.index.query.support.NestedScope in project elasticsearch by elastic.
the class ReverseNestedAggregationBuilder method doBuild.
@Override
protected AggregatorFactory<?> doBuild(SearchContext context, AggregatorFactory<?> parent, Builder subFactoriesBuilder) throws IOException {
if (findNestedAggregatorFactory(parent) == null) {
throw new SearchParseException(context, "Reverse nested aggregation [" + name + "] can only be used inside a [nested] aggregation", null);
}
ObjectMapper parentObjectMapper = null;
if (path != null) {
parentObjectMapper = context.getObjectMapper(path);
if (parentObjectMapper == null) {
return new ReverseNestedAggregatorFactory(name, true, null, context, parent, subFactoriesBuilder, metaData);
}
if (parentObjectMapper.nested().isNested() == false) {
throw new AggregationExecutionException("[reverse_nested] nested path [" + path + "] is not nested");
}
}
NestedScope nestedScope = context.getQueryShardContext().nestedScope();
try {
nestedScope.nextLevel(parentObjectMapper);
return new ReverseNestedAggregatorFactory(name, false, parentObjectMapper, context, parent, subFactoriesBuilder, metaData);
} finally {
nestedScope.previousLevel();
}
}
Aggregations