Class SamplerAggregator
- java.lang.Object
-
- org.elasticsearch.search.aggregations.BucketCollector
-
- org.elasticsearch.search.aggregations.Aggregator
-
- org.elasticsearch.search.aggregations.AggregatorBase
-
- org.elasticsearch.search.aggregations.bucket.BucketsAggregator
-
- org.elasticsearch.search.aggregations.bucket.DeferableBucketAggregator
-
- org.elasticsearch.search.aggregations.bucket.sampler.SamplerAggregator
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,org.apache.lucene.search.Collector
,Releasable
,SingleBucketAggregator
- Direct Known Subclasses:
DiversifiedBytesHashSamplerAggregator
,DiversifiedMapSamplerAggregator
,DiversifiedNumericSamplerAggregator
,DiversifiedOrdinalsSamplerAggregator
public class SamplerAggregator extends DeferableBucketAggregator implements SingleBucketAggregator
Aggregate on only the top-scoring docs on a shard. TODO currently the diversity feature of this agg offers only 'script' and 'field' as a means of generating a de-dup value. In future it would be nice if users could use any of the "bucket" aggs syntax (geo, date histogram...) as the basis for generating de-dup values. Their syntax for creating bucket values would be preferable to users having to recreate this logic in a 'script' e.g. to turn a datetime in milliseconds into a month key value.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SamplerAggregator.ExecutionMode
-
Nested classes/interfaces inherited from class org.elasticsearch.search.aggregations.Aggregator
Aggregator.Parser, Aggregator.SubAggCollectionMode
-
-
Field Summary
Fields Modifier and Type Field Description protected BestDocsDeferringCollector
bdd
static ParseField
EXECUTION_HINT_FIELD
static ParseField
MAX_DOCS_PER_VALUE_FIELD
static ParseField
SHARD_SIZE_FIELD
protected int
shardSize
-
Fields inherited from class org.elasticsearch.search.aggregations.AggregatorBase
collectableSubAggregators, context, DEFAULT_WEIGHT, name, parent, subAggregators
-
Fields inherited from class org.elasticsearch.search.aggregations.BucketCollector
NO_OP_COLLECTOR
-
-
Method Summary
Modifier and Type Method Description InternalAggregation
buildAggregation(long owningBucketOrdinal)
Build an aggregation for data that has been collected intobucket
.InternalAggregation
buildEmptyAggregation()
Build an empty aggregation.protected void
doClose()
Release instance-specific data.DeferringBucketCollector
getDeferringCollector()
protected LeafBucketCollector
getLeafCollector(org.apache.lucene.index.LeafReaderContext ctx, LeafBucketCollector sub)
Get aLeafBucketCollector
for the given ctx, which should delegate to the given collector.boolean
needsScores()
Most aggregators don't need scores, make sure to extend this method if your aggregator needs them.protected boolean
shouldDefer(Aggregator aggregator)
This method should be overridden by subclasses that want to defer calculation of a child aggregation until a first pass is complete and a set of buckets has been pruned.-
Methods inherited from class org.elasticsearch.search.aggregations.bucket.DeferableBucketAggregator
descendsFromGlobalAggregator, doPreCollection, runDeferredCollections
-
Methods inherited from class org.elasticsearch.search.aggregations.bucket.BucketsAggregator
bucketAggregations, bucketDocCount, bucketEmptyAggregations, close, collectBucket, collectExistingBucket, consumeBucketsAndMaybeBreak, getDocCounts, grow, incrementBucketDocCount, maxBucketOrd, mergeBuckets
-
Methods inherited from class org.elasticsearch.search.aggregations.AggregatorBase
addRequestCircuitBreakerBytes, buildEmptySubAggregations, context, doPostCollection, getLeafCollector, metaData, name, parent, pipelineAggregators, postCollection, preCollection, preGetSubLeafCollectors, subAggregator, subAggregators, toString
-
Methods inherited from class org.elasticsearch.search.aggregations.Aggregator
descendsFromBucketAggregator
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.elasticsearch.search.aggregations.bucket.SingleBucketAggregator
bucketDocCount
-
-
-
-
Field Detail
-
SHARD_SIZE_FIELD
public static final ParseField SHARD_SIZE_FIELD
-
MAX_DOCS_PER_VALUE_FIELD
public static final ParseField MAX_DOCS_PER_VALUE_FIELD
-
EXECUTION_HINT_FIELD
public static final ParseField EXECUTION_HINT_FIELD
-
shardSize
protected final int shardSize
-
bdd
protected BestDocsDeferringCollector bdd
-
-
Method Detail
-
needsScores
public boolean needsScores()
Description copied from class:AggregatorBase
Most aggregators don't need scores, make sure to extend this method if your aggregator needs them.- Specified by:
needsScores
in interfaceorg.apache.lucene.search.Collector
- Overrides:
needsScores
in classAggregatorBase
-
getDeferringCollector
public DeferringBucketCollector getDeferringCollector()
- Overrides:
getDeferringCollector
in classDeferableBucketAggregator
-
shouldDefer
protected boolean shouldDefer(Aggregator aggregator)
Description copied from class:DeferableBucketAggregator
This method should be overridden by subclasses that want to defer calculation of a child aggregation until a first pass is complete and a set of buckets has been pruned. Deferring collection will require the recording of all doc/bucketIds from the first pass and then the sub class should callDeferableBucketAggregator.runDeferredCollections(long...)
for the selected set of buckets that survive the pruning.- Overrides:
shouldDefer
in classDeferableBucketAggregator
- Parameters:
aggregator
- the child aggregator- Returns:
- true if the aggregator should be deferred until a first pass at collection has completed
-
buildAggregation
public InternalAggregation buildAggregation(long owningBucketOrdinal) throws java.io.IOException
Description copied from class:Aggregator
Build an aggregation for data that has been collected intobucket
.- Specified by:
buildAggregation
in classAggregator
- Throws:
java.io.IOException
-
buildEmptyAggregation
public InternalAggregation buildEmptyAggregation()
Description copied from class:Aggregator
Build an empty aggregation.- Specified by:
buildEmptyAggregation
in classAggregator
-
getLeafCollector
protected LeafBucketCollector getLeafCollector(org.apache.lucene.index.LeafReaderContext ctx, LeafBucketCollector sub) throws java.io.IOException
Description 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
-
doClose
protected void doClose()
Description copied from class:AggregatorBase
Release instance-specific data.- Overrides:
doClose
in classAggregatorBase
-
-