Class BucketOrder

    • Constructor Detail

      • BucketOrder

        public BucketOrder()
    • Method Detail

      • count

        public static BucketOrder count​(boolean asc)
        Creates a bucket ordering strategy that sorts buckets by their document counts (ascending or descending).
        Parameters:
        asc - direction to sort by: true for ascending, false for descending.
      • key

        public static BucketOrder key​(boolean asc)
        Creates a bucket ordering strategy that sorts buckets by their keys (ascending or descending). This may be used as a tie-breaker to avoid non-deterministic ordering.
        Parameters:
        asc - direction to sort by: true for ascending, false for descending.
      • aggregation

        public static BucketOrder aggregation​(java.lang.String path,
                                              boolean asc)
        Creates a bucket ordering strategy which sorts buckets based on a single-valued sub-aggregation.
        Parameters:
        path - path to the sub-aggregation to sort on.
        asc - direction to sort by: true for ascending, false for descending.
        See Also:
        AggregationPath
      • aggregation

        public static BucketOrder aggregation​(java.lang.String path,
                                              java.lang.String metricName,
                                              boolean asc)
        Creates a bucket ordering strategy which sorts buckets based on a metric from a multi-valued sub-aggregation.
        Parameters:
        path - path to the sub-aggregation to sort on.
        metricName - name of the value of the multi-value metric to sort on.
        asc - direction to sort by: true for ascending, false for descending.
        See Also:
        AggregationPath
      • compound

        public static BucketOrder compound​(java.util.List<BucketOrder> orders)
        Creates a bucket ordering strategy which sorts buckets based on multiple criteria. A tie-breaker may be added to avoid non-deterministic ordering.
        Parameters:
        orders - a list of BucketOrder objects to sort on, in order of priority.
      • compound

        public static BucketOrder compound​(BucketOrder... orders)
        Creates a bucket ordering strategy which sorts buckets based on multiple criteria. A tie-breaker may be added to avoid non-deterministic ordering.
        Parameters:
        orders - a list of BucketOrder parameters to sort on, in order of priority.
      • comparator

        public abstract java.util.Comparator<MultiBucketsAggregation.Bucket> comparator​(Aggregator aggregator)
        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.

      • hashCode

        public abstract int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public abstract boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object