Class AbstractInternalTerms<A extends AbstractInternalTerms<A,​B>,​B extends AbstractInternalTerms.AbstractTermsBucket>

java.lang.Object
org.elasticsearch.search.aggregations.InternalAggregation
org.elasticsearch.search.aggregations.InternalMultiBucketAggregation<A,​B>
org.elasticsearch.search.aggregations.bucket.terms.AbstractInternalTerms<A,​B>
All Implemented Interfaces:
NamedWriteable, Writeable, org.elasticsearch.common.xcontent.ToXContent, org.elasticsearch.common.xcontent.ToXContentFragment, Aggregation, MultiBucketsAggregation
Direct Known Subclasses:
InternalTerms

public abstract class AbstractInternalTerms<A extends AbstractInternalTerms<A,​B>,​B extends AbstractInternalTerms.AbstractTermsBucket>
extends InternalMultiBucketAggregation<A,​B>
Base class for terms and multi_terms aggregation that handles common reduce logic
  • Constructor Details

    • AbstractInternalTerms

      public AbstractInternalTerms​(java.lang.String name, java.util.Map<java.lang.String,​java.lang.Object> metadata)
    • AbstractInternalTerms

      protected AbstractInternalTerms​(StreamInput in) throws java.io.IOException
      Throws:
      java.io.IOException
  • Method Details

    • createBucketsArray

      protected abstract B[] createBucketsArray​(int size)
      Create an array to hold some buckets. Used in collecting the results.
    • create

      protected abstract A create​(java.lang.String name, java.util.List<B> buckets, BucketOrder reduceOrder, long docCountError, long otherDocCount)
      Creates InternalTerms at the end of the merge
    • getShardSize

      protected abstract int getShardSize()
    • getReduceOrder

      protected abstract BucketOrder getReduceOrder()
    • getOrder

      protected abstract BucketOrder getOrder()
    • getSumOfOtherDocCounts

      protected abstract long getSumOfOtherDocCounts()
    • getDocCountError

      protected abstract long getDocCountError()
    • setDocCountError

      protected abstract void setDocCountError​(long docCountError)
    • getMinDocCount

      protected abstract long getMinDocCount()
    • getRequiredSize

      protected abstract int getRequiredSize()
    • createBucket

      protected abstract B createBucket​(long docCount, InternalAggregations aggs, long docCountError, B prototype)
    • reduceBucket

      public B reduceBucket​(java.util.List<B> buckets, InternalAggregation.ReduceContext context)
      Description copied from class: InternalMultiBucketAggregation
      Reduce a list of same-keyed buckets (from multiple shards) to a single bucket. This requires all buckets to have the same key.
      Specified by:
      reduceBucket in class InternalMultiBucketAggregation<A extends AbstractInternalTerms<A,​B>,​B extends AbstractInternalTerms.AbstractTermsBucket>
    • reduce

      public InternalAggregation reduce​(java.util.List<InternalAggregation> aggregations, InternalAggregation.ReduceContext reduceContext)
      Description copied from class: InternalAggregation
      Reduces the given aggregations to a single one and returns it. In most cases, the assumption will be the all given aggregations are of the same type (the same type as this aggregation). For best efficiency, when implementing, try reusing an existing instance (typically the first in the given list) to save on redundant object construction.
      Specified by:
      reduce in class InternalAggregation
      See Also:
      InternalAggregation.mustReduceOnSingleInternalAgg()
    • doXContentCommon

      protected static org.elasticsearch.common.xcontent.XContentBuilder doXContentCommon​(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params, long docCountError, long otherDocCount, java.util.List<? extends AbstractInternalTerms.AbstractTermsBucket> buckets) throws java.io.IOException
      Throws:
      java.io.IOException