org.elasticsearch.search.aggregations.support.ValuesSource Java Examples
The following examples show how to use
org.elasticsearch.search.aggregations.support.ValuesSource.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExtendedStatsAggregator.java From Elasticsearch with Apache License 2.0 | 6 votes |
public ExtendedStatsAggregator(String name, ValuesSource.Numeric valuesSource, ValueFormatter formatter, AggregationContext context, Aggregator parent, double sigma, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException { super(name, context, parent, pipelineAggregators, metaData); this.valuesSource = valuesSource; this.formatter = formatter; this.sigma = sigma; if (valuesSource != null) { final BigArrays bigArrays = context.bigArrays(); counts = bigArrays.newLongArray(1, true); sums = bigArrays.newDoubleArray(1, true); mins = bigArrays.newDoubleArray(1, false); mins.fill(0, mins.size(), Double.POSITIVE_INFINITY); maxes = bigArrays.newDoubleArray(1, false); maxes.fill(0, maxes.size(), Double.NEGATIVE_INFINITY); sumOfSqrs = bigArrays.newDoubleArray(1, true); } }
Example #2
Source File: GeoShapeAggregator.java From elasticsearch-plugin-geoshape with MIT License | 6 votes |
public GeoShapeAggregator( String name, AggregatorFactories factories, SearchContext context, ValuesSource valuesSource, InternalGeoShape.OutputFormat output_format, boolean must_simplify, int zoom, GeoShape.Algorithm algorithm, BucketCountThresholds bucketCountThresholds, Aggregator parent, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData ) throws IOException { super(name, factories, context, parent, pipelineAggregators, metaData); this.valuesSource = valuesSource; this.output_format = output_format; this.must_simplify = must_simplify; this.zoom = zoom; this.algorithm = algorithm; bucketOrds = new BytesRefHash(1, context.bigArrays()); this.bucketCountThresholds = bucketCountThresholds; this.wkbReader = new WKBReader(); this.geometryFactory = new GeometryFactory(); }
Example #3
Source File: GeoCentroidParser.java From Elasticsearch with Apache License 2.0 | 6 votes |
@Override public AggregatorFactory parse(String aggregationName, XContentParser parser, SearchContext context) throws IOException { ValuesSourceParser<ValuesSource.GeoPoint> vsParser = ValuesSourceParser.geoPoint(aggregationName, InternalGeoCentroid.TYPE, context) .targetValueType(ValueType.GEOPOINT) .formattable(true) .build(); XContentParser.Token token; String currentFieldName = null; while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (vsParser.token(currentFieldName, token, parser)) { continue; } else { throw new SearchParseException(context, "Unknown key for a " + token + " in aggregation [" + aggregationName + "]: [" + currentFieldName + "].", parser.getTokenLocation()); } } return new GeoCentroidAggregator.Factory(aggregationName, vsParser.config()); }
Example #4
Source File: HistogramAggregator.java From Elasticsearch with Apache License 2.0 | 6 votes |
public HistogramAggregator(String name, AggregatorFactories factories, Rounding rounding, InternalOrder order, boolean keyed, long minDocCount, @Nullable ExtendedBounds extendedBounds, @Nullable ValuesSource.Numeric valuesSource, ValueFormatter formatter, InternalHistogram.Factory<?> histogramFactory, AggregationContext aggregationContext, Aggregator parent, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException { super(name, factories, aggregationContext, parent, pipelineAggregators, metaData); this.rounding = rounding; this.order = order; this.keyed = keyed; this.minDocCount = minDocCount; this.extendedBounds = extendedBounds; this.valuesSource = valuesSource; this.formatter = formatter; this.histogramFactory = histogramFactory; bucketOrds = new LongHash(1, aggregationContext.bigArrays()); }
Example #5
Source File: RangeAggregator.java From Elasticsearch with Apache License 2.0 | 6 votes |
public RangeAggregator(String name, AggregatorFactories factories, ValuesSource.Numeric valuesSource, ValueFormat format, InternalRange.Factory rangeFactory, List<Range> ranges, boolean keyed, AggregationContext aggregationContext, Aggregator parent, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException { super(name, factories, aggregationContext, parent, pipelineAggregators, metaData); assert valuesSource != null; this.valuesSource = valuesSource; this.formatter = format.formatter(); this.keyed = keyed; this.rangeFactory = rangeFactory; this.ranges = ranges.toArray(new Range[ranges.size()]); ValueParser parser = format != null ? format.parser() : ValueParser.RAW; for (int i = 0; i < this.ranges.length; i++) { this.ranges[i].process(parser, context.searchContext()); } sortRanges(this.ranges); maxTo = new double[this.ranges.length]; maxTo[0] = this.ranges[0].to; for (int i = 1; i < this.ranges.length; ++i) { maxTo[i] = Math.max(this.ranges[i].to,maxTo[i-1]); } }
Example #6
Source File: DateHierarchyAggregatorFactory.java From elasticsearch-aggregation-pathhierarchy with MIT License | 6 votes |
@Override protected Aggregator doCreateInternal( ValuesSource.Numeric valuesSource, SearchContext searchContext, Aggregator parent, boolean collectsFromSingleBucket, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException { DateHierarchyAggregator.BucketCountThresholds bucketCountThresholds = new DateHierarchyAggregator.BucketCountThresholds(this.bucketCountThresholds); if (!InternalOrder.isKeyOrder(order) && bucketCountThresholds.getShardSize() == DateHierarchyAggregationBuilder.DEFAULT_BUCKET_COUNT_THRESHOLDS.getShardSize()) { // The user has not made a shardSize selection. Use default // heuristic to avoid any wrong-ranking caused by distributed // counting bucketCountThresholds.setShardSize(BucketUtils.suggestShardSideQueueSize(bucketCountThresholds.getRequiredSize())); } bucketCountThresholds.ensureValidity(); return new DateHierarchyAggregator( name, factories, searchContext, valuesSource, order, minDocCount, bucketCountThresholds, roundingsInfo, parent, pipelineAggregators, metaData); }
Example #7
Source File: NumericValuesSourceMetricsAggregatorParser.java From Elasticsearch with Apache License 2.0 | 6 votes |
@Override public AggregatorFactory parse(String aggregationName, XContentParser parser, SearchContext context) throws IOException { ValuesSourceParser<ValuesSource.Numeric> vsParser = ValuesSourceParser.numeric(aggregationName, aggType, context).formattable(true) .build(); XContentParser.Token token; String currentFieldName = null; while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (!vsParser.token(currentFieldName, token, parser)) { throw new SearchParseException(context, "Unexpected token " + token + " in [" + aggregationName + "].", parser.getTokenLocation()); } } return createFactory(aggregationName, vsParser.config()); }
Example #8
Source File: DateHierarchyAggregatorFactory.java From elasticsearch-aggregation-pathhierarchy with MIT License | 6 votes |
DateHierarchyAggregatorFactory(String name, ValuesSourceConfig<ValuesSource.Numeric> config, BucketOrder order, List<DateHierarchyAggregationBuilder.RoundingInfo> roundingsInfo, long minDocCount, DateHierarchyAggregator.BucketCountThresholds bucketCountThresholds, QueryShardContext context, AggregatorFactory parent, AggregatorFactories.Builder subFactoriesBuilder, Map<String, Object> metaData ) throws IOException { super(name, config, context, parent, subFactoriesBuilder, metaData); this.order = order; this.roundingsInfo = roundingsInfo; this.minDocCount = minDocCount; this.bucketCountThresholds = bucketCountThresholds; }
Example #9
Source File: AbstractTDigestPercentilesAggregator.java From Elasticsearch with Apache License 2.0 | 5 votes |
public AbstractTDigestPercentilesAggregator(String name, ValuesSource.Numeric valuesSource, AggregationContext context, Aggregator parent, double[] keys, double compression, boolean keyed, ValueFormatter formatter, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException { super(name, context, parent, pipelineAggregators, metaData); this.valuesSource = valuesSource; this.keyed = keyed; this.formatter = formatter; this.states = context.bigArrays().newObjectArray(1); this.keys = keys; this.compression = compression; }
Example #10
Source File: CardinalityAggregator.java From Elasticsearch with Apache License 2.0 | 5 votes |
public CardinalityAggregator(String name, ValuesSource valuesSource, int precision, ValueFormatter formatter, AggregationContext context, Aggregator parent, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException { super(name, context, parent, pipelineAggregators, metaData); this.valuesSource = valuesSource; this.precision = precision; this.counts = valuesSource == null ? null : new HyperLogLogPlusPlus(precision, context.bigArrays(), 1); this.formatter = formatter; }
Example #11
Source File: ParentToChildrenAggregator.java From Elasticsearch with Apache License 2.0 | 5 votes |
public ParentToChildrenAggregator(String name, AggregatorFactories factories, AggregationContext aggregationContext, Aggregator parent, String parentType, Query childFilter, Query parentFilter, ValuesSource.Bytes.WithOrdinals.ParentChild valuesSource, long maxOrd, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException { super(name, factories, aggregationContext, parent, pipelineAggregators, metaData); this.parentType = parentType; // these two filters are cached in the parser this.childFilter = aggregationContext.searchContext().searcher().createNormalizedWeight(childFilter, false); this.parentFilter = aggregationContext.searchContext().searcher().createNormalizedWeight(parentFilter, false); this.parentOrdToBuckets = aggregationContext.bigArrays().newLongArray(maxOrd, false); this.parentOrdToBuckets.fill(0, maxOrd, -1); this.parentOrdToOtherBuckets = new LongObjectPagedHashMap<>(aggregationContext.bigArrays()); this.valuesSource = valuesSource; }
Example #12
Source File: TermsAggregatorFactory.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override Aggregator create(String name, AggregatorFactories factories, ValuesSource valuesSource, Terms.Order order, TermsAggregator.BucketCountThresholds bucketCountThresholds, IncludeExclude includeExclude, AggregationContext aggregationContext, Aggregator parent, SubAggCollectionMode subAggCollectMode, boolean showTermDocCountError, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException { final IncludeExclude.StringFilter filter = includeExclude == null ? null : includeExclude.convertToStringFilter(); return new StringTermsAggregator(name, factories, valuesSource, order, bucketCountThresholds, filter, aggregationContext, parent, subAggCollectMode, showTermDocCountError, pipelineAggregators, metaData); }
Example #13
Source File: ExtendedStatsParser.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public AggregatorFactory parse(String aggregationName, XContentParser parser, SearchContext context) throws IOException { ValuesSourceParser<ValuesSource.Numeric> vsParser = ValuesSourceParser.numeric(aggregationName, InternalExtendedStats.TYPE, context).formattable(true) .build(); XContentParser.Token token; String currentFieldName = null; double sigma = 2.0; while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (vsParser.token(currentFieldName, token, parser)) { continue; } else if (token == XContentParser.Token.VALUE_NUMBER) { if (context.parseFieldMatcher().match(currentFieldName, SIGMA)) { sigma = parser.doubleValue(); } else { throw new SearchParseException(context, "Unknown key for a " + token + " in [" + aggregationName + "]: [" + currentFieldName + "].", parser.getTokenLocation()); } } else { throw new SearchParseException(context, "Unexpected token " + token + " in [" + aggregationName + "].", parser.getTokenLocation()); } } if (sigma < 0) { throw new SearchParseException(context, "[sigma] must not be negative. Value provided was" + sigma, parser.getTokenLocation()); } return createFactory(aggregationName, vsParser.config(), sigma); }
Example #14
Source File: SumAggregator.java From Elasticsearch with Apache License 2.0 | 5 votes |
public SumAggregator(String name, ValuesSource.Numeric valuesSource, ValueFormatter formatter, AggregationContext context, Aggregator parent, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException { super(name, context, parent, pipelineAggregators, metaData); this.valuesSource = valuesSource; this.formatter = formatter; if (valuesSource != null) { sums = context.bigArrays().newDoubleArray(1, true); } }
Example #15
Source File: MaxAggregator.java From Elasticsearch with Apache License 2.0 | 5 votes |
public MaxAggregator(String name, ValuesSource.Numeric valuesSource, ValueFormatter formatter, AggregationContext context, Aggregator parent, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException { super(name, context, parent, pipelineAggregators, metaData); this.valuesSource = valuesSource; this.formatter = formatter; if (valuesSource != null) { maxes = context.bigArrays().newDoubleArray(1, false); maxes.fill(0, maxes.size(), Double.NEGATIVE_INFINITY); } }
Example #16
Source File: GlobalOrdinalsStringTermsAggregator.java From Elasticsearch with Apache License 2.0 | 5 votes |
public LowCardinality(String name, AggregatorFactories factories, ValuesSource.Bytes.WithOrdinals valuesSource, Terms.Order order, BucketCountThresholds bucketCountThresholds, AggregationContext aggregationContext, Aggregator parent, SubAggCollectionMode collectionMode, boolean showTermDocCountError, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException { super(name, factories, valuesSource, order, bucketCountThresholds, null, aggregationContext, parent, collectionMode, showTermDocCountError, pipelineAggregators, metaData); assert factories == null || factories.count() == 0; this.segmentDocCounts = context.bigArrays().newIntArray(1, true); }
Example #17
Source File: SignificantLongTermsAggregator.java From Elasticsearch with Apache License 2.0 | 5 votes |
public SignificantLongTermsAggregator(String name, AggregatorFactories factories, ValuesSource.Numeric valuesSource, ValueFormat format, BucketCountThresholds bucketCountThresholds, AggregationContext aggregationContext, Aggregator parent, SignificantTermsAggregatorFactory termsAggFactory, IncludeExclude.LongFilter includeExclude, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException { super(name, factories, valuesSource, format, null, bucketCountThresholds, aggregationContext, parent, SubAggCollectionMode.DEPTH_FIRST, false, includeExclude, pipelineAggregators, metaData); this.termsAggFactory = termsAggFactory; }
Example #18
Source File: HistogramAggregator.java From Elasticsearch with Apache License 2.0 | 5 votes |
public Factory(String name, ValuesSourceConfig<ValuesSource.Numeric> config, Rounding rounding, InternalOrder order, boolean keyed, long minDocCount, ExtendedBounds extendedBounds, InternalHistogram.Factory<?> histogramFactory) { super(name, histogramFactory.type(), config); this.rounding = rounding; this.order = order; this.keyed = keyed; this.minDocCount = minDocCount; this.extendedBounds = extendedBounds; this.histogramFactory = histogramFactory; }
Example #19
Source File: DiversifiedBytesHashSamplerAggregator.java From Elasticsearch with Apache License 2.0 | 5 votes |
public DiversifiedBytesHashSamplerAggregator(String name, int shardSize, AggregatorFactories factories, AggregationContext aggregationContext, Aggregator parent, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData, ValuesSource valuesSource, int maxDocsPerValue) throws IOException { super(name, shardSize, factories, aggregationContext, parent, pipelineAggregators, metaData); this.valuesSource = valuesSource; this.maxDocsPerValue = maxDocsPerValue; }
Example #20
Source File: PathHierarchyAggregatorFactory.java From elasticsearch-aggregation-pathhierarchy with MIT License | 5 votes |
private HierarchyValuesSource(ValuesSource values, BytesRef separator, int minDepth, int maxDepth, boolean twoSepAsOne){ this.values = values; this.separator = separator; this.minDepth = minDepth; this.maxDepth = maxDepth; this.twoSepAsOne = twoSepAsOne; }
Example #21
Source File: ValueCountAggregator.java From Elasticsearch with Apache License 2.0 | 5 votes |
public ValueCountAggregator(String name, ValuesSource valuesSource, ValueFormatter formatter, AggregationContext aggregationContext, Aggregator parent, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException { super(name, aggregationContext, parent, pipelineAggregators, metaData); this.valuesSource = valuesSource; this.formatter = formatter; if (valuesSource != null) { counts = context.bigArrays().newLongArray(1, true); } }
Example #22
Source File: GeoDistanceParser.java From Elasticsearch with Apache License 2.0 | 5 votes |
public DistanceSource(ValuesSource.GeoPoint source, GeoDistance distanceType, org.elasticsearch.common.geo.GeoPoint origin, DistanceUnit unit) { this.source = source; // even if the geo points are unique, there's no guarantee the distances are this.distanceType = distanceType; this.unit = unit; this.origin = origin; }
Example #23
Source File: GeoDistanceParser.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override protected Aggregator doCreateInternal(final ValuesSource.GeoPoint valuesSource, AggregationContext aggregationContext, Aggregator parent, boolean collectsFromSingleBucket, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException { DistanceSource distanceSource = new DistanceSource(valuesSource, distanceType, origin, unit); return new RangeAggregator(name, factories, distanceSource, config.format(), rangeFactory, ranges, keyed, aggregationContext, parent, pipelineAggregators, metaData); }
Example #24
Source File: SignificantTermsAggregatorFactory.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override Aggregator create(String name, AggregatorFactories factories, ValuesSource valuesSource, TermsAggregator.BucketCountThresholds bucketCountThresholds, IncludeExclude includeExclude, AggregationContext aggregationContext, Aggregator parent, SignificantTermsAggregatorFactory termsAggregatorFactory, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException { final IncludeExclude.StringFilter filter = includeExclude == null ? null : includeExclude.convertToStringFilter(); return new SignificantStringTermsAggregator(name, factories, valuesSource, bucketCountThresholds, filter, aggregationContext, parent, termsAggregatorFactory, pipelineAggregators, metaData); }
Example #25
Source File: GeoHashGridParser.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override protected Aggregator doCreateInternal(final ValuesSource.GeoPoint valuesSource, AggregationContext aggregationContext, Aggregator parent, boolean collectsFromSingleBucket, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException { if (collectsFromSingleBucket == false) { return asMultiBucketAggregator(this, aggregationContext, parent); } CellIdSource cellIdSource = new CellIdSource(valuesSource, precision); return new GeoHashGridAggregator(name, factories, cellIdSource, requiredSize, shardSize, aggregationContext, parent, pipelineAggregators, metaData); }
Example #26
Source File: GlobalOrdinalsStringTermsAggregator.java From Elasticsearch with Apache License 2.0 | 5 votes |
public GlobalOrdinalsStringTermsAggregator(String name, AggregatorFactories factories, ValuesSource.Bytes.WithOrdinals valuesSource, Terms.Order order, BucketCountThresholds bucketCountThresholds, IncludeExclude.OrdinalsFilter includeExclude, AggregationContext aggregationContext, Aggregator parent, SubAggCollectionMode collectionMode, boolean showTermDocCountError, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException { super(name, factories, aggregationContext, parent, order, bucketCountThresholds, collectionMode, showTermDocCountError, pipelineAggregators, metaData); this.valuesSource = valuesSource; this.includeExclude = includeExclude; }
Example #27
Source File: DiversifiedMapSamplerAggregator.java From Elasticsearch with Apache License 2.0 | 5 votes |
public DiversifiedMapSamplerAggregator(String name, int shardSize, AggregatorFactories factories, AggregationContext aggregationContext, Aggregator parent, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData, ValuesSource valuesSource, int maxDocsPerValue) throws IOException { super(name, shardSize, factories, aggregationContext, parent, pipelineAggregators, metaData); this.valuesSource = valuesSource; this.maxDocsPerValue = maxDocsPerValue; bucketOrds = new BytesRefHash(shardSize, aggregationContext.bigArrays()); }
Example #28
Source File: GeoDistanceParser.java From Elasticsearch with Apache License 2.0 | 5 votes |
public GeoDistanceFactory(String name, ValuesSourceConfig<ValuesSource.GeoPoint> valueSourceConfig, InternalRange.Factory rangeFactory, GeoPoint origin, DistanceUnit unit, GeoDistance distanceType, List<RangeAggregator.Range> ranges, boolean keyed) { super(name, rangeFactory.type(), valueSourceConfig); this.origin = origin; this.unit = unit; this.distanceType = distanceType; this.rangeFactory = rangeFactory; this.ranges = ranges; this.keyed = keyed; }
Example #29
Source File: SignificantStringTermsAggregator.java From Elasticsearch with Apache License 2.0 | 5 votes |
public SignificantStringTermsAggregator(String name, AggregatorFactories factories, ValuesSource valuesSource, BucketCountThresholds bucketCountThresholds, IncludeExclude.StringFilter includeExclude, AggregationContext aggregationContext, Aggregator parent, SignificantTermsAggregatorFactory termsAggFactory, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException { super(name, factories, valuesSource, null, bucketCountThresholds, includeExclude, aggregationContext, parent, SubAggCollectionMode.DEPTH_FIRST, false, pipelineAggregators, metaData); this.termsAggFactory = termsAggFactory; }
Example #30
Source File: GlobalOrdinalsSignificantTermsAggregator.java From Elasticsearch with Apache License 2.0 | 5 votes |
public WithHash(String name, AggregatorFactories factories, ValuesSource.Bytes.WithOrdinals.FieldData valuesSource, BucketCountThresholds bucketCountThresholds, IncludeExclude.OrdinalsFilter includeExclude, AggregationContext aggregationContext, Aggregator parent, SignificantTermsAggregatorFactory termsAggFactory, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException { super(name, factories, valuesSource, bucketCountThresholds, includeExclude, aggregationContext, parent, termsAggFactory, pipelineAggregators, metaData); bucketOrds = new LongHash(1, aggregationContext.bigArrays()); }