Class AggregatorFactory

java.lang.Object
org.elasticsearch.search.aggregations.AggregatorFactory
Direct Known Subclasses:
AdjacencyMatrixAggregatorFactory, FilterAggregatorFactory, FiltersAggregatorFactory, GlobalAggregatorFactory, MultiValuesSourceAggregatorFactory, NestedAggregatorFactory, ReverseNestedAggregatorFactory, SamplerAggregatorFactory, SignificantTextAggregatorFactory, ValuesSourceAggregatorFactory

public abstract class AggregatorFactory
extends java.lang.Object
  • Field Details

  • Constructor Details

    • AggregatorFactory

      public AggregatorFactory​(java.lang.String name, QueryShardContext queryShardContext, AggregatorFactory parent, AggregatorFactories.Builder subFactoriesBuilder, java.util.Map<java.lang.String,​java.lang.Object> metadata) throws java.io.IOException
      Constructs a new aggregator factory.
      Parameters:
      name - The aggregation name
      Throws:
      java.io.IOException - if an error occurs creating the factory
  • Method Details

    • name

      public java.lang.String name()
    • doValidate

      public void doValidate()
    • createInternal

      protected abstract Aggregator createInternal​(SearchContext searchContext, Aggregator parent, boolean collectsFromSingleBucket, java.util.Map<java.lang.String,​java.lang.Object> metadata) throws java.io.IOException
      Throws:
      java.io.IOException
    • create

      public final Aggregator create​(SearchContext searchContext, Aggregator parent, boolean collectsFromSingleBucket) throws java.io.IOException
      Creates the aggregator
      Parameters:
      searchContext - The search context
      parent - The parent aggregator (if this is a top level factory, the parent will be null)
      collectsFromSingleBucket - If true then the created aggregator will only be collected with 0 as a bucket ordinal. Some factories can take advantage of this in order to return more optimized implementations.
      Returns:
      The created aggregator
      Throws:
      java.io.IOException
    • getParent

      public AggregatorFactory getParent()
    • asMultiBucketAggregator

      protected static Aggregator asMultiBucketAggregator​(AggregatorFactory factory, SearchContext searchContext, Aggregator parent) throws java.io.IOException
      Utility method. Given an AggregatorFactory that creates Aggregators that only know how to collect bucket 0, this returns an aggregator that can collect any bucket.
      Throws:
      java.io.IOException
    • getStatsSubtype

      public java.lang.String getStatsSubtype()
      Returns the aggregation subtype for nodes usage stats.

      It should match the types registered by calling AggregationUsageService. In other words, it should be ValueSourcesType for the VST aggregations OTHER_SUBTYPE for all other aggregations.