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.-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classInternalOrder.AggregationMultiBucketsAggregation.Bucketordering strategy to sort by a sub-aggregation.static classInternalOrder.CompoundOrderMultiBucketsAggregation.Bucketordering strategy to sort by multiple criteria.static classInternalOrder.ParserContains logic for parsing aBucketOrderfrom aXContentParser.static classInternalOrder.StreamsContains logic for reading/writingBucketOrderfrom/to streams.Nested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.ParamsNested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V> -
Field Summary
Fields Modifier and Type Field Description protected booleanascprotected java.util.Comparator<MultiBucketsAggregation.Bucket>comparator -
Constructor Summary
Constructors Constructor Description InternalOrder(byte id, java.lang.String key, boolean asc, java.util.Comparator<MultiBucketsAggregation.Bucket> comparator)Creates an ordering strategy that sortsMultiBucketsAggregation.Buckets by some property. -
Method Summary
Modifier and Type Method Description java.util.Comparator<MultiBucketsAggregation.Bucket>comparator(Aggregator aggregator)booleanequals(java.lang.Object obj)inthashCode()static booleanisCountDesc(BucketOrder order)Determine if the ordering strategy is sorting on bucket count descending.static booleanisKeyAsc(BucketOrder order)Determine if the ordering strategy is sorting on bucket key ascending.static booleanisKeyDesc(BucketOrder order)Determine if the ordering strategy is sorting on bucket key descending.static booleanisKeyOrder(BucketOrder order)Determine if the ordering strategy is sorting on bucket key (ascending or descending).XContentBuildertoXContent(XContentBuilder builder, ToXContent.Params params)static BucketOrdervalidate(BucketOrder order, Aggregator aggregator)Validate a bucket ordering strategy for anAggregator.Methods inherited from class org.elasticsearch.search.aggregations.BucketOrder
aggregation, aggregation, compound, compound, count, key, toString, writeTo
-
Field Details
-
asc
protected final boolean asc -
comparator
-
-
Constructor Details
-
InternalOrder
public InternalOrder(byte id, java.lang.String key, boolean asc, java.util.Comparator<MultiBucketsAggregation.Bucket> comparator)Creates an ordering strategy that sortsMultiBucketsAggregation.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:truefor ascending,falsefor descending.comparator- determines how buckets will be ordered.
-
-
Method Details
-
comparator
- Specified by:
comparatorin classBucketOrder- 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 AggregationExecutionExceptionValidate a bucket ordering strategy for anAggregator.- Parameters:
order- bucket ordering strategy to sort on.aggregator- aggregator to sort.- Returns:
- unmodified bucket ordering strategy.
- Throws:
AggregationExecutionException- if validation fails
-
isCountDesc
Determine if the ordering strategy is sorting on bucket count descending.- Parameters:
order- bucket ordering strategy to check.- Returns:
trueif the ordering strategy is sorting on bucket count descending,falseotherwise.
-
isKeyOrder
Determine if the ordering strategy is sorting on bucket key (ascending or descending).- Parameters:
order- bucket ordering strategy to check.- Returns:
trueif the ordering strategy is sorting on bucket key,falseotherwise.
-
isKeyAsc
Determine if the ordering strategy is sorting on bucket key ascending.- Parameters:
order- bucket ordering strategy to check.- Returns:
trueif the ordering strategy is sorting on bucket key ascending,falseotherwise.
-
isKeyDesc
Determine if the ordering strategy is sorting on bucket key descending.- Parameters:
order- bucket ordering strategy to check.- Returns:
trueif the ordering strategy is sorting on bucket key descending,falseotherwise.
-
hashCode
public int hashCode()- Specified by:
hashCodein classBucketOrder
-
equals
public boolean equals(java.lang.Object obj)- Specified by:
equalsin classBucketOrder
-