Class InternalOrder

    • Constructor Detail

      • 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 Detail

      • 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.

      • 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.
      • equals

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