org.elasticsearch.search.aggregations.TopBucketBuilder<B>

public class TopBucketBuilder<B extends InternalMultiBucketAggregation.InternalBucket> extends
Merges many buckets into the "top" buckets as sorted by BucketOrder.
  • Constructor Summary

    Constructors
    Constructor
    Description
    TopBucketBuilder​(int size, BucketOrder order, <DelayedBucket<B>> nonCompetitive)
    Create a TopBucketBuilder to build a list of the top buckets.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add​(DelayedBucket<B> bucket)
    Add a bucket if it is competitive.
    <B>
    Return the most competitive buckets sorted by the comparator.

    Methods inherited from class java.lang.

    , , , , , , , , , ,
  • Constructor Details

    • TopBucketBuilder

      public TopBucketBuilder(int size, BucketOrder order, <DelayedBucket<B>> nonCompetitive)
      Create a TopBucketBuilder to build a list of the top buckets.
      Parameters:
      size - the requested size of the list
      order - the sort order of the buckets
      nonCompetitive - called with non-competitive buckets
  • Method Details

    • add

      public void add(DelayedBucket<B> bucket)
      Add a bucket if it is competitive. If there isn't space but the bucket is competitive then this will drop the least competitive bucket to make room for the new bucket.

      Instead of operating on complete buckets we this operates on a wrapper containing what we need to merge the buckets called DelayedBucket. We can evaluate some common sort criteria directly on the DelayedBuckets so we only need to merge exactly the sub-buckets we need.

    • build

      public <B> build()
      Return the most competitive buckets sorted by the comparator.