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.Bucket
ordering strategies.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
InternalOrder.Aggregation
MultiBucketsAggregation.Bucket
ordering strategy to sort by a sub-aggregation.static class
InternalOrder.CompoundOrder
MultiBucketsAggregation.Bucket
ordering strategy to sort by multiple criteria.static class
InternalOrder.Parser
Contains logic for parsing aBucketOrder
from aXContentParser
.static class
InternalOrder.Streams
Contains logic for reading/writingBucketOrder
from/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 boolean
asc
protected 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.Bucket
s by some property.
-
Method Summary
Modifier and Type Method Description java.util.Comparator<MultiBucketsAggregation.Bucket>
comparator(Aggregator aggregator)
boolean
equals(java.lang.Object obj)
int
hashCode()
static boolean
isCountDesc(BucketOrder order)
Determine if the ordering strategy is sorting on bucket count descending.static boolean
isKeyAsc(BucketOrder order)
Determine if the ordering strategy is sorting on bucket key ascending.static boolean
isKeyDesc(BucketOrder order)
Determine if the ordering strategy is sorting on bucket key descending.static boolean
isKeyOrder(BucketOrder order)
Determine if the ordering strategy is sorting on bucket key (ascending or descending).XContentBuilder
toXContent(XContentBuilder builder, ToXContent.Params params)
static BucketOrder
validate(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.Bucket
s 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 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:
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.
-
hashCode
public int hashCode()
- Specified by:
hashCode
in classBucketOrder
-
equals
public boolean equals(java.lang.Object obj)
- Specified by:
equals
in classBucketOrder
-
-