org.elasticsearch.search.aggregations.AggregatorFactories Java Examples
The following examples show how to use
org.elasticsearch.search.aggregations.AggregatorFactories.
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: 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 #2
Source File: ParseUtils.java From anomaly-detection with Apache License 2.0 | 6 votes |
public static SearchSourceBuilder generatePreviewQuery( AnomalyDetector detector, List<Entry<Long, Long>> ranges, NamedXContentRegistry xContentRegistry ) throws IOException { DateRangeAggregationBuilder dateRangeBuilder = dateRange("date_range").field(detector.getTimeField()).format("epoch_millis"); for (Entry<Long, Long> range : ranges) { dateRangeBuilder.addRange(range.getKey(), range.getValue()); } if (detector.getFeatureAttributes() != null) { for (Feature feature : detector.getFeatureAttributes()) { AggregatorFactories.Builder internalAgg = parseAggregators( feature.getAggregation().toString(), xContentRegistry, feature.getId() ); dateRangeBuilder.subAggregation(internalAgg.getAggregatorFactories().iterator().next()); } } return new SearchSourceBuilder().query(detector.getFilterQuery()).size(0).aggregation(dateRangeBuilder); }
Example #3
Source File: ParseUtils.java From anomaly-detection with Apache License 2.0 | 6 votes |
public static String generateInternalFeatureQueryTemplate(AnomalyDetector detector, NamedXContentRegistry xContentRegistry) throws IOException { RangeQueryBuilder rangeQuery = new RangeQueryBuilder(detector.getTimeField()) .from("{{" + QUERY_PARAM_PERIOD_START + "}}") .to("{{" + QUERY_PARAM_PERIOD_END + "}}"); BoolQueryBuilder internalFilterQuery = QueryBuilders.boolQuery().must(rangeQuery).must(detector.getFilterQuery()); SearchSourceBuilder internalSearchSourceBuilder = new SearchSourceBuilder().query(internalFilterQuery); if (detector.getFeatureAttributes() != null) { for (Feature feature : detector.getFeatureAttributes()) { AggregatorFactories.Builder internalAgg = parseAggregators( feature.getAggregation().toString(), xContentRegistry, feature.getId() ); internalSearchSourceBuilder.aggregation(internalAgg.getAggregatorFactories().iterator().next()); } } return internalSearchSourceBuilder.toString(); }
Example #4
Source File: GeoShapeAggregatorFactory.java From elasticsearch-plugin-geoshape with MIT License | 6 votes |
GeoShapeAggregatorFactory(String name, ValuesSourceConfig<ValuesSource> config, InternalGeoShape.OutputFormat output_format, boolean must_simplify, int zoom, GeoShape.Algorithm algorithm, GeoShapeAggregator.BucketCountThresholds bucketCountThresholds, QueryShardContext context, AggregatorFactory parent, AggregatorFactories.Builder subFactoriesBuilder, Map<String, Object> metaData ) throws IOException { super(name, config, context, parent, subFactoriesBuilder, metaData); this.output_format = output_format; this.must_simplify = must_simplify; this.zoom = zoom; this.algorithm = algorithm; this.bucketCountThresholds = bucketCountThresholds; }
Example #5
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 #6
Source File: PathHierarchyAggregator.java From elasticsearch-aggregation-pathhierarchy with MIT License | 6 votes |
public PathHierarchyAggregator( String name, AggregatorFactories factories, SearchContext context, ValuesSource valuesSource, BucketOrder order, long minDocCount, BucketCountThresholds bucketCountThresholds, BytesRef separator, int minDepth, Aggregator parent, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData ) throws IOException { super(name, factories, context, parent, pipelineAggregators, metaData); this.valuesSource = valuesSource; this.separator = separator; this.minDocCount = minDocCount; bucketOrds = new BytesRefHash(1, context.bigArrays()); this.order = InternalOrder.validate(order, this); this.bucketCountThresholds = bucketCountThresholds; this.minDepth = minDepth; }
Example #7
Source File: DateHierarchyAggregator.java From elasticsearch-aggregation-pathhierarchy with MIT License | 6 votes |
public DateHierarchyAggregator( String name, AggregatorFactories factories, SearchContext context, ValuesSource.Numeric valuesSource, BucketOrder order, long minDocCount, BucketCountThresholds bucketCountThresholds, List<DateHierarchyAggregationBuilder.RoundingInfo> roundingsInfo, Aggregator parent, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData ) throws IOException { super(name, factories, context, parent, pipelineAggregators, metaData); this.valuesSource = valuesSource; this.roundingsInfo = roundingsInfo; this.minDocCount = minDocCount; bucketOrds = new BytesRefHash(1, context.bigArrays()); this.order = InternalOrder.validate(order, this); this.bucketCountThresholds = bucketCountThresholds; }
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: PathHierarchyAggregatorFactory.java From elasticsearch-aggregation-pathhierarchy with MIT License | 6 votes |
PathHierarchyAggregatorFactory(String name, ValuesSourceConfig<ValuesSource> config, String separator, int minDepth, int maxDepth, boolean keepBlankPath, BucketOrder order, long minDocCount, PathHierarchyAggregator.BucketCountThresholds bucketCountThresholds, QueryShardContext context, AggregatorFactory parent, AggregatorFactories.Builder subFactoriesBuilder, Map<String, Object> metaData ) throws IOException { super(name, config, context, parent, subFactoriesBuilder, metaData); this.separator = new BytesRef(separator); this.minDepth = minDepth; this.maxDepth = maxDepth; this.keepBlankPath = keepBlankPath; this.order = order; this.minDocCount = minDocCount; this.bucketCountThresholds = bucketCountThresholds; }
Example #10
Source File: PathHierarchyAggregationBuilder.java From elasticsearch-aggregation-pathhierarchy with MIT License | 6 votes |
@Override protected ValuesSourceAggregatorFactory<ValuesSource> innerBuild( QueryShardContext context, ValuesSourceConfig<ValuesSource> config, AggregatorFactory parent, AggregatorFactories.Builder subFactoriesBuilder) throws IOException { if (minDepth > maxDepth) throw new IllegalArgumentException("[minDepth] (" + minDepth + ") must not be greater than [maxDepth] (" + maxDepth + ")"); if (depth >= 0) { if (minDepth > depth) throw new IllegalArgumentException("[minDepth] (" + minDepth + ") must not be greater than [depth] (" + depth + ")"); minDepth = depth; maxDepth = depth; } return new PathHierarchyAggregatorFactory( name, config, separator, minDepth, maxDepth, keepBlankPath, order, minDocCount, bucketCountThresholds, context, parent, subFactoriesBuilder, metaData); }
Example #11
Source File: FiltersAggregator.java From Elasticsearch with Apache License 2.0 | 6 votes |
public FiltersAggregator(String name, AggregatorFactories factories, String[] keys, Weight[] filters, boolean keyed, String otherBucketKey, AggregationContext aggregationContext, Aggregator parent, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException { super(name, factories, aggregationContext, parent, pipelineAggregators, metaData); this.keyed = keyed; this.keys = keys; this.filters = filters; this.showOtherBucket = otherBucketKey != null; this.otherBucketKey = otherBucketKey; if (showOtherBucket) { this.totalNumKeys = keys.length + 1; } else { this.totalNumKeys = keys.length; } }
Example #12
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 #13
Source File: BaseAggregatorFactory.java From elasticsearch-linear-regression with Apache License 2.0 | 5 votes |
public BaseAggregatorFactory(final String name, final List<ValuesSourceConfig<Numeric>> featureConfigs, final ValuesSourceConfig<Numeric> responseConfig, final SearchContext context, final AggregatorFactory<?> parent, final AggregatorFactories.Builder subFactoriesBuilder, final Map<String, Object> metaData) throws IOException { super(name, context, parent, subFactoriesBuilder, metaData); this.featureConfigs = featureConfigs; this.responseConfig = responseConfig; }
Example #14
Source File: DiversifiedOrdinalsSamplerAggregator.java From Elasticsearch with Apache License 2.0 | 5 votes |
public DiversifiedOrdinalsSamplerAggregator(String name, int shardSize, AggregatorFactories factories, AggregationContext aggregationContext, Aggregator parent, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData, ValuesSource.Bytes.WithOrdinals.FieldData valuesSource, int maxDocsPerValue) throws IOException { super(name, shardSize, factories, aggregationContext, parent, pipelineAggregators, metaData); this.valuesSource = valuesSource; this.maxDocsPerValue = maxDocsPerValue; }
Example #15
Source File: BaseAggregationBuilder.java From elasticsearch-linear-regression with Apache License 2.0 | 5 votes |
@Override protected final MultiValuesSourceAggregatorFactory<ValuesSource.Numeric, ?> innerBuild( final SearchContext context, final List<NamedValuesSourceConfigSpec<Numeric>> configs, final AggregatorFactory<?> parent, final AggregatorFactories.Builder subFactoriesBuilder) throws IOException { return innerInnerBuild(context, configs, this.multiValueMode, parent, subFactoriesBuilder); }
Example #16
Source File: FilterAggregator.java From Elasticsearch with Apache License 2.0 | 5 votes |
public FilterAggregator(String name, Weight filter, AggregatorFactories factories, AggregationContext aggregationContext, Aggregator parent, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException { super(name, factories, aggregationContext, parent, pipelineAggregators, metaData); this.filter = filter; }
Example #17
Source File: ReverseNestedAggregator.java From Elasticsearch with Apache License 2.0 | 5 votes |
public ReverseNestedAggregator(String name, AggregatorFactories factories, ObjectMapper objectMapper, AggregationContext aggregationContext, Aggregator parent, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException { super(name, factories, aggregationContext, parent, pipelineAggregators, metaData); if (objectMapper == null) { parentFilter = Queries.newNonNestedFilter(); } else { parentFilter = objectMapper.nestedTypeFilter(); } parentBitsetProducer = context.searchContext().bitsetFilterCache().getBitSetProducer(parentFilter); }
Example #18
Source File: GeoHashGridAggregator.java From Elasticsearch with Apache License 2.0 | 5 votes |
public GeoHashGridAggregator(String name, AggregatorFactories factories, GeoHashGridParser.GeoGridFactory.CellIdSource valuesSource, int requiredSize, int shardSize, AggregationContext aggregationContext, Aggregator parent, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException { super(name, factories, aggregationContext, parent, pipelineAggregators, metaData); this.valuesSource = valuesSource; this.requiredSize = requiredSize; this.shardSize = shardSize; bucketOrds = new LongHash(1, aggregationContext.bigArrays()); }
Example #19
Source File: DiversifiedNumericSamplerAggregator.java From Elasticsearch with Apache License 2.0 | 5 votes |
public DiversifiedNumericSamplerAggregator(String name, int shardSize, AggregatorFactories factories, AggregationContext aggregationContext, Aggregator parent, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData, ValuesSource.Numeric valuesSource, int maxDocsPerValue) throws IOException { super(name, shardSize, factories, aggregationContext, parent, pipelineAggregators, metaData); this.valuesSource = valuesSource; this.maxDocsPerValue = maxDocsPerValue; }
Example #20
Source File: StatsAggregationBuilder.java From elasticsearch-linear-regression with Apache License 2.0 | 5 votes |
@Override protected StatsAggregatorFactory innerInnerBuild(final SearchContext context, final List<NamedValuesSourceConfigSpec<Numeric>> configs, final MultiValueMode multiValueMode, final AggregatorFactory<?> parent, final AggregatorFactories.Builder subFactoriesBuilder) throws IOException { return new StatsAggregatorFactory(this.name, configs, multiValueMode, context, parent, subFactoriesBuilder, this.metaData); }
Example #21
Source File: StatsAggregatorFactory.java From elasticsearch-linear-regression with Apache License 2.0 | 5 votes |
public StatsAggregatorFactory(String name, List<NamedValuesSourceConfigSpec<Numeric>> configs, MultiValueMode multiValueMode, SearchContext context, AggregatorFactory<?> parent, AggregatorFactories.Builder subFactoriesBuilder, Map<String, Object> metaData) throws IOException { super(name, configs, context, parent, subFactoriesBuilder, metaData); this.multiValueMode = multiValueMode; }
Example #22
Source File: MultiValuesSourceAggregationBuilder.java From elasticsearch-linear-regression with Apache License 2.0 | 5 votes |
@Override protected final MultiValuesSourceAggregatorFactory<VS, ?> doBuild(SearchContext context, AggregatorFactory<?> parent, AggregatorFactories.Builder subFactoriesBuilder) throws IOException { List<NamedValuesSourceConfigSpec<VS>> configs = resolveConfig(context); MultiValuesSourceAggregatorFactory<VS, ?> factory = innerBuild(context, configs, parent, subFactoriesBuilder); return factory; }
Example #23
Source File: MultiValuesSourceAggregatorFactory.java From elasticsearch-linear-regression with Apache License 2.0 | 5 votes |
public MultiValuesSourceAggregatorFactory(String name, List<NamedValuesSourceConfigSpec<VS>> configs, SearchContext context, AggregatorFactory<?> parent, AggregatorFactories.Builder subFactoriesBuilder, Map<String, Object> metaData) throws IOException { super(name, context, parent, subFactoriesBuilder, metaData); this.configs = configs; }
Example #24
Source File: GeoShapeBuilder.java From elasticsearch-plugin-geoshape with MIT License | 5 votes |
@Override protected ValuesSourceAggregatorFactory<ValuesSource> innerBuild( QueryShardContext queryShardContext, ValuesSourceConfig<ValuesSource> config, AggregatorFactory parent, AggregatorFactories.Builder subFactoriesBuilder) throws IOException { return new GeoShapeAggregatorFactory( name, config, output_format, must_simplify, simplify_zoom, simplify_algorithm, bucketCountThresholds, queryShardContext, parent, subFactoriesBuilder, metaData); }
Example #25
Source File: TopKAggregator.java From elasticsearch-topk-plugin with Apache License 2.0 | 5 votes |
public TopKAggregator(String name, Number size, Number capacity, AggregatorFactories factories, long estimatedBucketsCount, ValuesSource.Bytes valuesSource, AggregationContext aggregationContext, Aggregator parent) { super(name, factories, aggregationContext, parent); this.size = size; this.capacity = capacity; this.valuesSource = valuesSource; if (valuesSource != null) { final long initialSize = estimatedBucketsCount < 2 ? 1 : estimatedBucketsCount; this.summaries = bigArrays.newObjectArray(initialSize); this.bucketOrds = bigArrays.newObjectArray(initialSize); this.termToBucket = bigArrays.newObjectArray(initialSize); } }
Example #26
Source File: GeoPointClusteringAggregatorFactory.java From elasticsearch-aggregation-geoclustering with Apache License 2.0 | 5 votes |
GeoPointClusteringAggregatorFactory( String name, ValuesSourceConfig<GeoPoint> config, int precision, double radius, double ratio, int requiredSize, int shardSize, QueryShardContext context, AggregatorFactory parent, AggregatorFactories.Builder subFactoriesBuilder, Map<String, Object> metaData ) throws IOException { super(name, config, context, parent, subFactoriesBuilder, metaData); this.precision = precision; this.radius = radius; this.ratio = ratio; this.requiredSize = requiredSize; this.shardSize = shardSize; }
Example #27
Source File: GeoPointClusteringAggregator.java From elasticsearch-aggregation-geoclustering with Apache License 2.0 | 5 votes |
GeoPointClusteringAggregator( String name, AggregatorFactories factories, ValuesSource.GeoPoint valuesSource, int precision, double radius, double ratio, int requiredSize, int shardSize, SearchContext aggregationContext, Aggregator parent, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData ) throws IOException { super(name, factories, aggregationContext, parent, pipelineAggregators, metaData); this.valuesSource = valuesSource; this.precision = precision; this.radius = radius; this.ratio = ratio; this.requiredSize = requiredSize; this.shardSize = shardSize; bucketOrds = new LongHash(1, aggregationContext.bigArrays()); centroids = context.bigArrays().newObjectArray(1); }
Example #28
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 #29
Source File: ParseUtils.java From anomaly-detection with Apache License 2.0 | 5 votes |
public static SearchSourceBuilder generateInternalFeatureQuery( AnomalyDetector detector, long startTime, long endTime, NamedXContentRegistry xContentRegistry ) throws IOException { RangeQueryBuilder rangeQuery = new RangeQueryBuilder(detector.getTimeField()) .from(startTime) .to(endTime) .format("epoch_millis") .includeLower(true) .includeUpper(false); BoolQueryBuilder internalFilterQuery = QueryBuilders.boolQuery().must(rangeQuery).must(detector.getFilterQuery()); SearchSourceBuilder internalSearchSourceBuilder = new SearchSourceBuilder().query(internalFilterQuery); if (detector.getFeatureAttributes() != null) { for (Feature feature : detector.getFeatureAttributes()) { AggregatorFactories.Builder internalAgg = parseAggregators( feature.getAggregation().toString(), xContentRegistry, feature.getId() ); internalSearchSourceBuilder.aggregation(internalAgg.getAggregatorFactories().iterator().next()); } } return internalSearchSourceBuilder; }
Example #30
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; }