org.elasticsearch.search.aggregations.Aggregator Java Examples

The following examples show how to use org.elasticsearch.search.aggregations.Aggregator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StatsAggregator.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
public StatsAggregator(String name, ValuesSource.Numeric valuesSource, ValueFormatter formatter,
                       AggregationContext context,
                       Aggregator parent, List<PipelineAggregator> pipelineAggregators,
                       Map<String, Object> metaData) throws IOException {
    super(name, context, parent, pipelineAggregators, metaData);
    this.valuesSource = valuesSource;
    if (valuesSource != null) {
        final BigArrays bigArrays = context.bigArrays();
        counts = bigArrays.newLongArray(1, true);
        sums = bigArrays.newDoubleArray(1, true);
        mins = bigArrays.newDoubleArray(1, false);
        mins.fill(0, mins.size(), Double.POSITIVE_INFINITY);
        maxes = bigArrays.newDoubleArray(1, false);
        maxes.fill(0, maxes.size(), Double.NEGATIVE_INFINITY);
    }
    this.formatter = formatter;
}
 
Example #2
Source File: DateHierarchyAggregatorFactory.java    From elasticsearch-aggregation-pathhierarchy with MIT License 6 votes vote down vote up
@Override
protected Aggregator doCreateInternal(
        ValuesSource.Numeric valuesSource, SearchContext searchContext, Aggregator parent,
        boolean collectsFromSingleBucket, List<PipelineAggregator> pipelineAggregators,
        Map<String, Object> metaData) throws IOException {

    DateHierarchyAggregator.BucketCountThresholds bucketCountThresholds = new
            DateHierarchyAggregator.BucketCountThresholds(this.bucketCountThresholds);
    if (!InternalOrder.isKeyOrder(order)
            && bucketCountThresholds.getShardSize() == DateHierarchyAggregationBuilder.DEFAULT_BUCKET_COUNT_THRESHOLDS.getShardSize()) {
        // The user has not made a shardSize selection. Use default
        // heuristic to avoid any wrong-ranking caused by distributed
        // counting
        bucketCountThresholds.setShardSize(BucketUtils.suggestShardSideQueueSize(bucketCountThresholds.getRequiredSize()));
    }
    bucketCountThresholds.ensureValidity();
    return new DateHierarchyAggregator(
            name, factories, searchContext,
            valuesSource, order, minDocCount, bucketCountThresholds, roundingsInfo,
            parent, pipelineAggregators, metaData);
}
 
Example #3
Source File: ExtendedStatsAggregator.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
public ExtendedStatsAggregator(String name, ValuesSource.Numeric valuesSource, ValueFormatter formatter,
        AggregationContext context, Aggregator parent, double sigma, List<PipelineAggregator> pipelineAggregators,
        Map<String, Object> metaData)
        throws IOException {
    super(name, context, parent, pipelineAggregators, metaData);
    this.valuesSource = valuesSource;
    this.formatter = formatter;
    this.sigma = sigma;
    if (valuesSource != null) {
        final BigArrays bigArrays = context.bigArrays();
        counts = bigArrays.newLongArray(1, true);
        sums = bigArrays.newDoubleArray(1, true);
        mins = bigArrays.newDoubleArray(1, false);
        mins.fill(0, mins.size(), Double.POSITIVE_INFINITY);
        maxes = bigArrays.newDoubleArray(1, false);
        maxes.fill(0, maxes.size(), Double.NEGATIVE_INFINITY);
        sumOfSqrs = bigArrays.newDoubleArray(1, true);
    }
}
 
Example #4
Source File: HistogramAggregator.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
public HistogramAggregator(String name, AggregatorFactories factories, Rounding rounding, InternalOrder order, boolean keyed,
        long minDocCount, @Nullable ExtendedBounds extendedBounds, @Nullable ValuesSource.Numeric valuesSource,
        ValueFormatter formatter, InternalHistogram.Factory<?> histogramFactory, AggregationContext aggregationContext,
        Aggregator parent, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException {

    super(name, factories, aggregationContext, parent, pipelineAggregators, metaData);
    this.rounding = rounding;
    this.order = order;
    this.keyed = keyed;
    this.minDocCount = minDocCount;
    this.extendedBounds = extendedBounds;
    this.valuesSource = valuesSource;
    this.formatter = formatter;
    this.histogramFactory = histogramFactory;

    bucketOrds = new LongHash(1, aggregationContext.bigArrays());
}
 
Example #5
Source File: FiltersAggregator.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
public FiltersAggregator(String name, AggregatorFactories factories, String[] keys, Weight[] filters, boolean keyed, String otherBucketKey,
        AggregationContext aggregationContext,
        Aggregator parent, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData)
        throws IOException {
    super(name, factories, aggregationContext, parent, pipelineAggregators, metaData);
    this.keyed = keyed;
    this.keys = keys;
    this.filters = filters;
    this.showOtherBucket = otherBucketKey != null;
    this.otherBucketKey = otherBucketKey;
    if (showOtherBucket) {
        this.totalNumKeys = keys.length + 1;
    } else {
        this.totalNumKeys = keys.length;
    }
}
 
Example #6
Source File: DateHierarchyAggregator.java    From elasticsearch-aggregation-pathhierarchy with MIT License 6 votes vote down vote up
public DateHierarchyAggregator(
        String name,
        AggregatorFactories factories,
        SearchContext context,
        ValuesSource.Numeric valuesSource,
        BucketOrder order,
        long minDocCount,
        BucketCountThresholds bucketCountThresholds,
        List<DateHierarchyAggregationBuilder.RoundingInfo> roundingsInfo,
        Aggregator parent,
        List<PipelineAggregator> pipelineAggregators,
        Map<String, Object> metaData
) throws IOException {
    super(name, factories, context, parent, pipelineAggregators, metaData);
    this.valuesSource = valuesSource;
    this.roundingsInfo = roundingsInfo;
    this.minDocCount = minDocCount;
    bucketOrds =  new BytesRefHash(1, context.bigArrays());
    this.order = InternalOrder.validate(order, this);
    this.bucketCountThresholds = bucketCountThresholds;
}
 
Example #7
Source File: ReverseNestedAggregator.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Override
public Aggregator createInternal(AggregationContext context, Aggregator parent, boolean collectsFromSingleBucket,
        List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException {
    // Early validation
    NestedAggregator closestNestedAggregator = findClosestNestedAggregator(parent);
    if (closestNestedAggregator == null) {
        throw new SearchParseException(context.searchContext(), "Reverse nested aggregation [" + name
                + "] can only be used inside a [nested] aggregation", null);
    }

    final ObjectMapper objectMapper;
    if (path != null) {
        objectMapper = context.searchContext().getObjectMapper(path);
        if (objectMapper == null) {
            return new Unmapped(name, context, parent, pipelineAggregators, metaData);
        }
        if (!objectMapper.nested().isNested()) {
            throw new AggregationExecutionException("[reverse_nested] nested path [" + path + "] is not nested");
        }
    } else {
        objectMapper = null;
    }
    return new ReverseNestedAggregator(name, factories, objectMapper, context, parent, pipelineAggregators, metaData);
}
 
Example #8
Source File: ScriptedMetricAggregator.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
protected ScriptedMetricAggregator(String name, Script initScript, Script mapScript, Script combineScript, Script reduceScript,
        Map<String, Object> params, AggregationContext context, Aggregator parent, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData)
        throws IOException {
    super(name, context, parent, pipelineAggregators, metaData);
    this.params = params;
    ScriptService scriptService = context.searchContext().scriptService();
    if (initScript != null) {
        scriptService.executable(initScript, ScriptContext.Standard.AGGS, context.searchContext(), Collections.<String, String>emptyMap()).run();
    }
    this.mapScript = scriptService.search(context.searchContext().lookup(), mapScript, ScriptContext.Standard.AGGS, Collections.<String, String>emptyMap());
    if (combineScript != null) {
        this.combineScript = scriptService.executable(combineScript, ScriptContext.Standard.AGGS, context.searchContext(), Collections.<String, String>emptyMap());
    } else {
        this.combineScript = null;
    }
    this.reduceScript = reduceScript;
}
 
Example #9
Source File: PathHierarchyAggregatorFactory.java    From elasticsearch-aggregation-pathhierarchy with MIT License 6 votes vote down vote up
@Override
protected Aggregator doCreateInternal(
        ValuesSource valuesSource, SearchContext searchContext, Aggregator parent,
        boolean collectsFromSingleBucket, List<PipelineAggregator> pipelineAggregators,
        Map<String, Object> metaData) throws IOException {

    ValuesSource valuesSourceBytes = new HierarchyValuesSource(valuesSource, separator, minDepth, maxDepth, keepBlankPath);
    PathHierarchyAggregator.BucketCountThresholds bucketCountThresholds = new
            PathHierarchyAggregator.BucketCountThresholds(this.bucketCountThresholds);
    if (!InternalOrder.isKeyOrder(order)
            && bucketCountThresholds.getShardSize() == PathHierarchyAggregationBuilder.DEFAULT_BUCKET_COUNT_THRESHOLDS.getShardSize()) {
        // The user has not made a shardSize selection. Use default
        // heuristic to avoid any wrong-ranking caused by distributed
        // counting
        bucketCountThresholds.setShardSize(BucketUtils.suggestShardSideQueueSize(bucketCountThresholds.getRequiredSize()));
    }
    bucketCountThresholds.ensureValidity();
    return new PathHierarchyAggregator(
            name, factories, searchContext,
            valuesSourceBytes, order, minDocCount, bucketCountThresholds, separator, minDepth,
            parent, pipelineAggregators, metaData);
}
 
Example #10
Source File: ParentToChildrenAggregator.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
protected Aggregator createUnmapped(AggregationContext aggregationContext, Aggregator parent, List<PipelineAggregator> pipelineAggregators,
        Map<String, Object> metaData) throws IOException {
    return new NonCollectingAggregator(name, aggregationContext, parent, pipelineAggregators, metaData) {

        @Override
        public InternalAggregation buildEmptyAggregation() {
            return new InternalChildren(name, 0, buildEmptySubAggregations(), pipelineAggregators(), metaData());
        }

    };
}
 
Example #11
Source File: MinAggregator.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
public MinAggregator(String name, ValuesSource.Numeric valuesSource, ValueFormatter formatter,
        AggregationContext context, Aggregator parent, List<PipelineAggregator> pipelineAggregators,
        Map<String, Object> metaData) throws IOException {
    super(name, context, parent, pipelineAggregators, metaData);
    this.valuesSource = valuesSource;
    if (valuesSource != null) {
        mins = context.bigArrays().newDoubleArray(1, false);
        mins.fill(0, mins.size(), Double.POSITIVE_INFINITY);
    }
    this.formatter = formatter;
}
 
Example #12
Source File: AggregationPath.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
/**
 * Resolves the topmost aggregator pointed by this path using the given root as a point of reference.
 *
 * @param root      The point of reference of this path
 * @return          The first child aggregator of the root pointed by this path
 */
public Aggregator resolveTopmostAggregator(Aggregator root) {
    AggregationPath.PathElement token = pathElements.get(0);
    Aggregator aggregator = root.subAggregator(token.name);
    assert (aggregator instanceof SingleBucketAggregator )
            || (aggregator instanceof NumericMetricsAggregator) : "this should be picked up before aggregation execution - on validate";
    return aggregator;
}
 
Example #13
Source File: GeoPointClusteringAggregator.java    From elasticsearch-aggregation-geoclustering with Apache License 2.0 5 votes vote down vote up
GeoPointClusteringAggregator(
        String name, AggregatorFactories factories, ValuesSource.GeoPoint valuesSource, int precision,
        double radius, double ratio, int requiredSize, int shardSize, SearchContext aggregationContext,
        Aggregator parent, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData
) throws IOException {
    super(name, factories, aggregationContext, parent, pipelineAggregators, metaData);
    this.valuesSource = valuesSource;
    this.precision = precision;
    this.radius = radius;
    this.ratio = ratio;
    this.requiredSize = requiredSize;
    this.shardSize = shardSize;
    bucketOrds = new LongHash(1, aggregationContext.bigArrays());
    centroids = context.bigArrays().newObjectArray(1);
}
 
Example #14
Source File: NestedAggregator.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
private static Query findClosestNestedPath(Aggregator parent) {
    for (; parent != null; parent = parent.parent()) {
        if (parent instanceof NestedAggregator) {
            return ((NestedAggregator) parent).childFilter;
        } else if (parent instanceof ReverseNestedAggregator) {
            return ((ReverseNestedAggregator) parent).getParentFilter();
        }
    }
    return null;
}
 
Example #15
Source File: ReverseNestedAggregator.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
public ReverseNestedAggregator(String name, AggregatorFactories factories, ObjectMapper objectMapper,
        AggregationContext aggregationContext, Aggregator parent, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData)
        throws IOException {
    super(name, factories, aggregationContext, parent, pipelineAggregators, metaData);
    if (objectMapper == null) {
        parentFilter = Queries.newNonNestedFilter();
    } else {
        parentFilter = objectMapper.nestedTypeFilter();
    }
    parentBitsetProducer = context.searchContext().bitsetFilterCache().getBitSetProducer(parentFilter);
}
 
Example #16
Source File: GlobalOrdinalsSignificantTermsAggregator.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
public GlobalOrdinalsSignificantTermsAggregator(String name, AggregatorFactories factories,
        ValuesSource.Bytes.WithOrdinals.FieldData valuesSource, BucketCountThresholds bucketCountThresholds,
        IncludeExclude.OrdinalsFilter includeExclude, AggregationContext aggregationContext, Aggregator parent,
        SignificantTermsAggregatorFactory termsAggFactory, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData)
        throws IOException {

    super(name, factories, valuesSource, null, bucketCountThresholds, includeExclude, aggregationContext, parent,
            SubAggCollectionMode.DEPTH_FIRST, false, pipelineAggregators, metaData);
    this.termsAggFactory = termsAggFactory;
}
 
Example #17
Source File: SignificantStringTermsAggregator.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
public SignificantStringTermsAggregator(String name, AggregatorFactories factories, ValuesSource valuesSource,
           BucketCountThresholds bucketCountThresholds,
           IncludeExclude.StringFilter includeExclude, AggregationContext aggregationContext, Aggregator parent,
SignificantTermsAggregatorFactory termsAggFactory, List<PipelineAggregator> pipelineAggregators,
           Map<String, Object> metaData)
           throws IOException {

       super(name, factories, valuesSource, null, bucketCountThresholds, includeExclude, aggregationContext, parent,
               SubAggCollectionMode.DEPTH_FIRST, false, pipelineAggregators, metaData);
       this.termsAggFactory = termsAggFactory;
   }
 
Example #18
Source File: ValuesSourceAggregatorFactory.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public Aggregator createInternal(AggregationContext context, Aggregator parent, boolean collectsFromSingleBucket,
        List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException {
    VS vs = context.valuesSource(config, context.searchContext());
    if (vs == null) {
        return createUnmapped(context, parent, pipelineAggregators, metaData);
    }
    return doCreateInternal(vs, context, parent, collectsFromSingleBucket, pipelineAggregators, metaData);
}
 
Example #19
Source File: ValueCountAggregator.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
protected Aggregator doCreateInternal(VS valuesSource, AggregationContext aggregationContext, Aggregator parent,
        boolean collectsFromSingleBucket, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData)
        throws IOException {
    return new ValueCountAggregator(name, valuesSource, config.formatter(), aggregationContext, parent, pipelineAggregators,
            metaData);
}
 
Example #20
Source File: StatsAggregatorFactory.java    From elasticsearch-linear-regression with Apache License 2.0 5 votes vote down vote up
@Override
protected Aggregator createUnmapped(Aggregator parent,
    List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData)
    throws IOException {
  return new StatsAggregator(name, null, context, parent, multiValueMode,
      pipelineAggregators, metaData);
}
 
Example #21
Source File: ParentToChildrenAggregator.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
protected Aggregator doCreateInternal(ValuesSource.Bytes.WithOrdinals.ParentChild valuesSource,
        AggregationContext aggregationContext, Aggregator parent, boolean collectsFromSingleBucket, List<PipelineAggregator> pipelineAggregators,
        Map<String, Object> metaData) throws IOException {
    long maxOrd = valuesSource.globalMaxOrd(aggregationContext.searchContext().searcher(), parentType);
    return new ParentToChildrenAggregator(name, factories, aggregationContext, parent, parentType, childFilter, parentFilter,
            valuesSource, maxOrd, pipelineAggregators, metaData);
}
 
Example #22
Source File: GeoCentroidAggregator.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
protected GeoCentroidAggregator(String name, AggregationContext aggregationContext, Aggregator parent,
                                ValuesSource.GeoPoint valuesSource, List<PipelineAggregator> pipelineAggregators,
                                Map<String, Object> metaData) throws IOException {
    super(name, aggregationContext, parent, pipelineAggregators, metaData);
    this.valuesSource = valuesSource;
    if (valuesSource != null) {
        final BigArrays bigArrays = context.bigArrays();
        centroids = bigArrays.newLongArray(1, true);
        counts = bigArrays.newLongArray(1, true);
    }
}
 
Example #23
Source File: StringTermsAggregator.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
public StringTermsAggregator(String name, AggregatorFactories factories, ValuesSource valuesSource,
        Terms.Order order, BucketCountThresholds bucketCountThresholds,
        IncludeExclude.StringFilter includeExclude, AggregationContext aggregationContext,
        Aggregator parent, SubAggCollectionMode collectionMode, boolean showTermDocCountError, List<PipelineAggregator> pipelineAggregators,
        Map<String, Object> metaData) throws IOException {

    super(name, factories, aggregationContext, parent, order, bucketCountThresholds, collectionMode, showTermDocCountError, pipelineAggregators,
            metaData);
    this.valuesSource = valuesSource;
    this.includeExclude = includeExclude;
    bucketOrds = new BytesRefHash(1, aggregationContext.bigArrays());
}
 
Example #24
Source File: DiversifiedNumericSamplerAggregator.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
public DiversifiedNumericSamplerAggregator(String name, int shardSize, AggregatorFactories factories,
        AggregationContext aggregationContext, Aggregator parent, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData,
        ValuesSource.Numeric valuesSource, int maxDocsPerValue) throws IOException {
    super(name, shardSize, factories, aggregationContext, parent, pipelineAggregators, metaData);
    this.valuesSource = valuesSource;
    this.maxDocsPerValue = maxDocsPerValue;
}
 
Example #25
Source File: BaseSamplingAggregator.java    From elasticsearch-linear-regression with Apache License 2.0 5 votes vote down vote up
public BaseSamplingAggregator(final String name,
    final List<NamedValuesSourceSpec<Numeric>> valuesSources,
    final SearchContext context,
    final Aggregator parent, final MultiValueMode multiValueMode,
    final List<PipelineAggregator> pipelineAggregators,
    final Map<String, Object> metaData) throws IOException {
  super(name, context, parent, pipelineAggregators, metaData);
  if (valuesSources != null && !valuesSources.isEmpty()) {
    this.valuesSources = new NumericMultiValuesSource(valuesSources, multiValueMode);
    this.samplings = context.bigArrays().newObjectArray(1);
    this.fieldsCount = this.valuesSources.fieldNames().length;
  } else {
    this.valuesSources = null;
  }
}
 
Example #26
Source File: SumAggregator.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
public SumAggregator(String name, ValuesSource.Numeric valuesSource, ValueFormatter formatter, AggregationContext context,
        Aggregator parent, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException {
    super(name, context, parent, pipelineAggregators, metaData);
    this.valuesSource = valuesSource;
    this.formatter = formatter;
    if (valuesSource != null) {
        sums = context.bigArrays().newDoubleArray(1, true);
    }
}
 
Example #27
Source File: GeoHashGridAggregator.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
public GeoHashGridAggregator(String name, AggregatorFactories factories, GeoHashGridParser.GeoGridFactory.CellIdSource valuesSource,
        int requiredSize, int shardSize, AggregationContext aggregationContext, Aggregator parent, List<PipelineAggregator> pipelineAggregators,
        Map<String, Object> metaData) throws IOException {
    super(name, factories, aggregationContext, parent, pipelineAggregators, metaData);
    this.valuesSource = valuesSource;
    this.requiredSize = requiredSize;
    this.shardSize = shardSize;
    bucketOrds = new LongHash(1, aggregationContext.bigArrays());
}
 
Example #28
Source File: LongTermsAggregator.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
public LongTermsAggregator(String name, AggregatorFactories factories, ValuesSource.Numeric valuesSource, ValueFormat format,
        Terms.Order order, BucketCountThresholds bucketCountThresholds, AggregationContext aggregationContext, Aggregator parent,
        SubAggCollectionMode subAggCollectMode, boolean showTermDocCountError, IncludeExclude.LongFilter longFilter,
        List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException {
    super(name, factories, aggregationContext, parent, bucketCountThresholds, order, subAggCollectMode, pipelineAggregators, metaData);
    this.valuesSource = valuesSource;
    this.showTermDocCountError = showTermDocCountError;
    this.formatter = format.formatter();
    this.longFilter = longFilter;
    bucketOrds = new LongHash(1, aggregationContext.bigArrays());
}
 
Example #29
Source File: DoubleTermsAggregator.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
public DoubleTermsAggregator(String name, AggregatorFactories factories, ValuesSource.Numeric valuesSource, ValueFormat format,
        Terms.Order order, BucketCountThresholds bucketCountThresholds, AggregationContext aggregationContext, Aggregator parent,
        SubAggCollectionMode collectionMode, boolean showTermDocCountError, IncludeExclude.LongFilter longFilter,
        List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException {
    super(name, factories, valuesSource, format, order, bucketCountThresholds, aggregationContext, parent, collectionMode,
            showTermDocCountError, longFilter, pipelineAggregators, metaData);
}
 
Example #30
Source File: NestedAggregator.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public Aggregator createInternal(AggregationContext context, Aggregator parent, boolean collectsFromSingleBucket,
        List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException {
    if (collectsFromSingleBucket == false) {
        return asMultiBucketAggregator(this, context, parent);
    }
    ObjectMapper objectMapper = context.searchContext().getObjectMapper(path);
    if (objectMapper == null) {
        return new Unmapped(name, context, parent, pipelineAggregators, metaData);
    }
    if (!objectMapper.nested().isNested()) {
        throw new AggregationExecutionException("[nested] nested path [" + path + "] is not nested");
    }
    return new NestedAggregator(name, factories, objectMapper, context, parent, pipelineAggregators, metaData);
}