Search in sources :

Example 1 with NestedScope

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;
}
Also used : NestedScope(org.elasticsearch.index.query.support.NestedScope)

Example 2 with NestedScope

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();
    }
}
Also used : SearchParseException(org.elasticsearch.search.SearchParseException) NestedScope(org.elasticsearch.index.query.support.NestedScope) AggregationExecutionException(org.elasticsearch.search.aggregations.AggregationExecutionException) ObjectMapper(org.elasticsearch.index.mapper.ObjectMapper)

Aggregations

NestedScope (org.elasticsearch.index.query.support.NestedScope)2 ObjectMapper (org.elasticsearch.index.mapper.ObjectMapper)1 SearchParseException (org.elasticsearch.search.SearchParseException)1 AggregationExecutionException (org.elasticsearch.search.aggregations.AggregationExecutionException)1