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 forMultiBucketsAggregation.Bucketordering 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.Params
-
Nested 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-
Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS
-
-
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
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.elasticsearch.common.xcontent.ToXContentObject
isFragment
-
-
-
-
Field Detail
-
asc
protected final boolean asc
-
comparator
protected final java.util.Comparator<MultiBucketsAggregation.Bucket> comparator
-
-
Constructor Detail
-
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 Detail
-
comparator
public java.util.Comparator<MultiBucketsAggregation.Bucket> comparator(Aggregator aggregator)
- 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 AggregationExecutionException
Validate 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
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:
trueif the ordering strategy is sorting on bucket count descending,falseotherwise.
-
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:
trueif the ordering strategy is sorting on bucket key,falseotherwise.
-
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:
trueif the ordering strategy is sorting on bucket key ascending,falseotherwise.
-
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:
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
-
-