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 classSamplerAggregator.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 BestDocsDeferringCollectorbddstatic ParseFieldEXECUTION_HINT_FIELDstatic ParseFieldMAX_DOCS_PER_VALUE_FIELDstatic ParseFieldSHARD_SIZE_FIELDprotected intshardSize-
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 InternalAggregationbuildAggregation(long owningBucketOrdinal)Build an aggregation for data that has been collected intobucket.InternalAggregationbuildEmptyAggregation()Build an empty aggregation.protected voiddoClose()Release instance-specific data.DeferringBucketCollectorgetDeferringCollector()protected LeafBucketCollectorgetLeafCollector(org.apache.lucene.index.LeafReaderContext ctx, LeafBucketCollector sub)Get aLeafBucketCollectorfor the given ctx, which should delegate to the given collector.org.apache.lucene.search.ScoreModescoreMode()Most aggregators don't need scores, make sure to extend this method if your aggregator needs them.protected booleanshouldDefer(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
-
scoreMode
public org.apache.lucene.search.ScoreMode scoreMode()
Description copied from class:AggregatorBaseMost aggregators don't need scores, make sure to extend this method if your aggregator needs them.- Specified by:
scoreModein interfaceorg.apache.lucene.search.Collector- Overrides:
scoreModein classAggregatorBase
-
getDeferringCollector
public DeferringBucketCollector getDeferringCollector()
- Overrides:
getDeferringCollectorin classDeferableBucketAggregator
-
shouldDefer
protected boolean shouldDefer(Aggregator aggregator)
Description copied from class:DeferableBucketAggregatorThis 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:
shouldDeferin 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:AggregatorBuild an aggregation for data that has been collected intobucket.- Specified by:
buildAggregationin classAggregator- Throws:
java.io.IOException
-
buildEmptyAggregation
public InternalAggregation buildEmptyAggregation()
Description copied from class:AggregatorBuild an empty aggregation.- Specified by:
buildEmptyAggregationin classAggregator
-
getLeafCollector
protected LeafBucketCollector getLeafCollector(org.apache.lucene.index.LeafReaderContext ctx, LeafBucketCollector sub) throws java.io.IOException
Description copied from class:AggregatorBaseGet aLeafBucketCollectorfor the given ctx, which should delegate to the given collector.- Specified by:
getLeafCollectorin classAggregatorBase- Throws:
java.io.IOException
-
doClose
protected void doClose()
Description copied from class:AggregatorBaseRelease instance-specific data.- Overrides:
doClosein classAggregatorBase
-
-