Class BucketOrder
- java.lang.Object
-
- org.elasticsearch.search.aggregations.BucketOrder
-
- All Implemented Interfaces:
Writeable
,ToXContent
,ToXContentObject
- Direct Known Subclasses:
InternalOrder
,InternalOrder.CompoundOrder
public abstract class BucketOrder extends java.lang.Object implements ToXContentObject, Writeable
MultiBucketsAggregation.Bucket
Ordering strategy.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params
-
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>
-
-
Field Summary
-
Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS
-
-
Constructor Summary
Constructors Constructor Description BucketOrder()
-
Method Summary
Modifier and Type Method Description static BucketOrder
aggregation(java.lang.String path, boolean asc)
Creates a bucket ordering strategy which sorts buckets based on a single-valued sub-aggregation.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.abstract java.util.Comparator<MultiBucketsAggregation.Bucket>
comparator(Aggregator aggregator)
static BucketOrder
compound(java.util.List<BucketOrder> orders)
Creates a bucket ordering strategy which sorts buckets based on multiple criteria.static BucketOrder
compound(BucketOrder... orders)
Creates a bucket ordering strategy which sorts buckets based on multiple criteria.static BucketOrder
count(boolean asc)
Creates a bucket ordering strategy that sorts buckets by their document counts (ascending or descending).abstract boolean
equals(java.lang.Object obj)
abstract int
hashCode()
static BucketOrder
key(boolean asc)
Creates a bucket ordering strategy that sorts buckets by their keys (ascending or descending).java.lang.String
toString()
void
writeTo(StreamOutput out)
Write this into the StreamOutput.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.elasticsearch.common.xcontent.ToXContent
toXContent
-
Methods inherited from interface org.elasticsearch.common.xcontent.ToXContentObject
isFragment
-
-
-
-
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 ofBucketOrder
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 ofBucketOrder
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 classjava.lang.Object
-
equals
public abstract boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
writeTo
public void writeTo(StreamOutput out) throws java.io.IOException
Description copied from interface:Writeable
Write this into the StreamOutput.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-