Class InternalOrder

java.lang.Object
org.elasticsearch.search.aggregations.BucketOrder
org.elasticsearch.search.aggregations.InternalOrder
All Implemented Interfaces:
Writeable, ToXContent, ToXContentObject
Direct Known Subclasses:
InternalOrder.Aggregation

public class InternalOrder
extends BucketOrder
Implementations for MultiBucketsAggregation.Bucket ordering strategies.
  • Field Details

  • Constructor Details

    • InternalOrder

      public InternalOrder​(byte id, java.lang.String key, boolean asc, java.util.Comparator<MultiBucketsAggregation.Bucket> comparator)
      Creates an ordering strategy that sorts MultiBucketsAggregation.Buckets by some property.
      Parameters:
      id - unique ID for this ordering strategy.
      key - key of the property to sort on.
      asc - direction to sort by: true for ascending, false for descending.
      comparator - determines how buckets will be ordered.
  • Method Details

    • comparator

      public java.util.Comparator<MultiBucketsAggregation.Bucket> comparator​(Aggregator aggregator)
      Specified by:
      comparator in class BucketOrder
      Returns:
      A comparator for the bucket based on the given aggregator. The comparator is used in two phases:

      - aggregation phase, where each shard builds a list of buckets to be sent to the coordinating node. In this phase, the passed in aggregator will be the aggregator that aggregates the buckets on the shard level.

      - reduce phase, where the coordinating node gathers all the buckets from all the shards and reduces them to a final bucket list. In this case, the passed in aggregator will be null.

    • toXContent

      public XContentBuilder toXContent​(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
      Throws:
      java.io.IOException
    • validate

      public static BucketOrder validate​(BucketOrder order, Aggregator aggregator) throws AggregationExecutionException
      Validate a bucket ordering strategy for an Aggregator.
      Parameters:
      order - bucket ordering strategy to sort on.
      aggregator - aggregator to sort.
      Returns:
      unmodified bucket ordering strategy.
      Throws:
      AggregationExecutionException - if validation fails
    • isCountDesc

      public static boolean isCountDesc​(BucketOrder order)
      Determine if the ordering strategy is sorting on bucket count descending.
      Parameters:
      order - bucket ordering strategy to check.
      Returns:
      true if the ordering strategy is sorting on bucket count descending, false otherwise.
    • isKeyOrder

      public static boolean isKeyOrder​(BucketOrder order)
      Determine if the ordering strategy is sorting on bucket key (ascending or descending).
      Parameters:
      order - bucket ordering strategy to check.
      Returns:
      true if the ordering strategy is sorting on bucket key, false otherwise.
    • isKeyAsc

      public static boolean isKeyAsc​(BucketOrder order)
      Determine if the ordering strategy is sorting on bucket key ascending.
      Parameters:
      order - bucket ordering strategy to check.
      Returns:
      true if the ordering strategy is sorting on bucket key ascending, false otherwise.
    • isKeyDesc

      public static boolean isKeyDesc​(BucketOrder order)
      Determine if the ordering strategy is sorting on bucket key descending.
      Parameters:
      order - bucket ordering strategy to check.
      Returns:
      true if the ordering strategy is sorting on bucket key descending, false otherwise.
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in class BucketOrder
    • equals

      public boolean equals​(java.lang.Object obj)
      Specified by:
      equals in class BucketOrder