Class CardinalityAggregator
java.lang.Object
org.elasticsearch.search.aggregations.BucketCollector
org.elasticsearch.search.aggregations.Aggregator
org.elasticsearch.search.aggregations.AggregatorBase
org.elasticsearch.search.aggregations.metrics.MetricsAggregator
org.elasticsearch.search.aggregations.metrics.NumericMetricsAggregator
org.elasticsearch.search.aggregations.metrics.NumericMetricsAggregator.SingleValue
org.elasticsearch.search.aggregations.metrics.CardinalityAggregator
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,org.apache.lucene.search.Collector
,Releasable
public class CardinalityAggregator extends NumericMetricsAggregator.SingleValue
An aggregator that computes approximate counts of unique values.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.elasticsearch.search.aggregations.metrics.NumericMetricsAggregator
NumericMetricsAggregator.MultiValue, NumericMetricsAggregator.SingleValue
Nested classes/interfaces inherited from class org.elasticsearch.search.aggregations.Aggregator
Aggregator.BucketComparator, Aggregator.Parser, Aggregator.SubAggCollectionMode
-
Field Summary
Fields inherited from class org.elasticsearch.search.aggregations.AggregatorBase
collectableSubAggregators, DEFAULT_WEIGHT, name, parent, subAggregators
Fields inherited from class org.elasticsearch.search.aggregations.BucketCollector
NO_OP_COLLECTOR
-
Constructor Summary
Constructors Constructor Description CardinalityAggregator(java.lang.String name, ValuesSourceConfig valuesSourceConfig, int precision, AggregationContext context, Aggregator parent, java.util.Map<java.lang.String,java.lang.Object> metadata)
-
Method Summary
Modifier and Type Method Description InternalAggregation
buildAggregation(long owningBucketOrdinal)
Build an aggregation for data that has been collected intoowningBucketOrd
.InternalAggregation
buildEmptyAggregation()
Build an empty aggregation.void
collectDebugInfo(java.util.function.BiConsumer<java.lang.String,java.lang.Object> add)
Collect debug information to add to the profiling results.protected void
doClose()
Release instance-specific data.protected void
doPostCollection()
Can be overridden by aggregator implementation to be called back when the collection phase ends.LeafBucketCollector
getLeafCollector(org.apache.lucene.index.LeafReaderContext ctx, LeafBucketCollector sub)
Get aLeafBucketCollector
for the given ctx, which should delegate to the given collector.double
metric(long owningBucketOrd)
org.apache.lucene.search.ScoreMode
scoreMode()
Most aggregators don't need scores, make sure to extend this method if your aggregator needs them.Methods inherited from class org.elasticsearch.search.aggregations.metrics.NumericMetricsAggregator.SingleValue
bucketComparator
Methods inherited from class org.elasticsearch.search.aggregations.metrics.MetricsAggregator
buildAggregations
Methods inherited from class org.elasticsearch.search.aggregations.AggregatorBase
addRequestCircuitBreakerBytes, bigArrays, buildEmptySubAggregations, close, doPreCollection, getLeafCollector, metadata, name, parent, pointReaderIfAvailable, postCollection, preCollection, preGetSubLeafCollectors, searcher, subAggregator, subAggregators, topLevelQuery, toString
Methods inherited from class org.elasticsearch.search.aggregations.Aggregator
buildTopLevel, resolveSortPath, resolveSortPathOnValidAgg
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Constructor Details
-
CardinalityAggregator
public CardinalityAggregator(java.lang.String name, ValuesSourceConfig valuesSourceConfig, int precision, AggregationContext context, Aggregator parent, java.util.Map<java.lang.String,java.lang.Object> metadata) throws java.io.IOException- Throws:
java.io.IOException
-
-
Method Details
-
scoreMode
public org.apache.lucene.search.ScoreMode scoreMode()Description copied from class:AggregatorBase
Most aggregators don't need scores, make sure to extend this method if your aggregator needs them.- Specified by:
scoreMode
in interfaceorg.apache.lucene.search.Collector
- Overrides:
scoreMode
in classAggregatorBase
-
getLeafCollector
public LeafBucketCollector getLeafCollector(org.apache.lucene.index.LeafReaderContext ctx, LeafBucketCollector sub) throws java.io.IOExceptionDescription copied from class:AggregatorBase
Get aLeafBucketCollector
for the given ctx, which should delegate to the given collector.- Specified by:
getLeafCollector
in classAggregatorBase
- Throws:
java.io.IOException
-
doPostCollection
protected void doPostCollection() throws java.io.IOExceptionDescription copied from class:AggregatorBase
Can be overridden by aggregator implementation to be called back when the collection phase ends.- Overrides:
doPostCollection
in classAggregatorBase
- Throws:
java.io.IOException
-
metric
public double metric(long owningBucketOrd)- Specified by:
metric
in classNumericMetricsAggregator.SingleValue
-
buildAggregation
Description copied from class:MetricsAggregator
Build an aggregation for data that has been collected intoowningBucketOrd
.- Specified by:
buildAggregation
in classMetricsAggregator
-
buildEmptyAggregation
Description copied from class:Aggregator
Build an empty aggregation.- Specified by:
buildEmptyAggregation
in classAggregator
-
doClose
protected void doClose()Description copied from class:AggregatorBase
Release instance-specific data.- Overrides:
doClose
in classAggregatorBase
-
collectDebugInfo
public void collectDebugInfo(java.util.function.BiConsumer<java.lang.String,java.lang.Object> add)Description copied from class:Aggregator
Collect debug information to add to the profiling results. This will only be called if the aggregation is being profiled.Well behaved implementations will always call the superclass implementation just in case it has something interesting. They will also only add objects which can be serialized with
StreamOutput.writeGenericValue(Object)
andXContentBuilder.value(Object)
. And they'll have an integration test.- Overrides:
collectDebugInfo
in classAggregator
-