org.elasticsearch.search.aggregations.support.ValuesSourceConfig Java Examples
The following examples show how to use
org.elasticsearch.search.aggregations.support.ValuesSourceConfig.
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: BaseAggregatorFactory.java From elasticsearch-linear-regression with Apache License 2.0 | 6 votes |
@Override public Aggregator createInternal(final Aggregator parent, final boolean collectsFromSingleBucket, final List<PipelineAggregator> pipelineAggregators, final Map<String, Object> metaData) throws IOException { final List<Numeric> featuresValuesSources = new ArrayList<>(this.featureConfigs.size()); for (final ValuesSourceConfig<Numeric> featureConfig : this.featureConfigs) { Numeric source = featureConfig.toValuesSource(this.context.getQueryShardContext()); if (source == null) { source = Numeric.EMPTY; } featuresValuesSources.add(source); } Numeric responseSource = this.responseConfig .toValuesSource(this.context.getQueryShardContext()); if (responseSource == null) { responseSource = Numeric.EMPTY; } return doCreateInternal(featuresValuesSources, responseSource, parent, collectsFromSingleBucket, pipelineAggregators, metaData); }
Example #2
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 #3
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 #4
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 #5
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 #6
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 #7
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 #8
Source File: SignificantTermsAggregatorFactory.java From Elasticsearch with Apache License 2.0 | 5 votes |
public SignificantTermsAggregatorFactory(String name, ValuesSourceConfig valueSourceConfig, TermsAggregator.BucketCountThresholds bucketCountThresholds, IncludeExclude includeExclude, String executionHint, Query filter, SignificanceHeuristic significanceHeuristic) { super(name, SignificantStringTerms.TYPE.name(), valueSourceConfig); this.bucketCountThresholds = bucketCountThresholds; this.includeExclude = includeExclude; this.executionHint = executionHint; this.significanceHeuristic = significanceHeuristic; if (!valueSourceConfig.unmapped()) { this.indexedFieldName = config.fieldContext().field(); fieldType = SearchContext.current().smartNameFieldType(indexedFieldName); } this.filter = filter; }
Example #9
Source File: TermsAggregatorFactory.java From Elasticsearch with Apache License 2.0 | 5 votes |
public TermsAggregatorFactory(String name, ValuesSourceConfig config, Terms.Order order, TermsAggregator.BucketCountThresholds bucketCountThresholds, IncludeExclude includeExclude, String executionHint, SubAggCollectionMode executionMode, boolean showTermDocCountError) { super(name, StringTerms.TYPE.name(), config); this.order = order; this.includeExclude = includeExclude; this.executionHint = executionHint; this.bucketCountThresholds = bucketCountThresholds; this.collectMode = executionMode; this.showTermDocCountError = showTermDocCountError; }
Example #10
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 #11
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 #12
Source File: DateHierarchyAggregationBuilder.java From elasticsearch-aggregation-pathhierarchy with MIT License | 5 votes |
@Override protected ValuesSourceAggregatorFactory<ValuesSource.Numeric> innerBuild( QueryShardContext context, ValuesSourceConfig<ValuesSource.Numeric> config, AggregatorFactory parent, Builder subFactoriesBuilder) throws IOException { final List<RoundingInfo> roundingsInfo = buildRoundings(); return new DateHierarchyAggregatorFactory( name, config, order, roundingsInfo, minDocCount, bucketCountThresholds, context, parent, subFactoriesBuilder, metaData); }
Example #13
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 #14
Source File: PercentilesParser.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override protected AggregatorFactory buildFactory(SearchContext context, String aggregationName, ValuesSourceConfig<Numeric> valuesSourceConfig, double[] keys, PercentilesMethod method, Double compression, Integer numberOfSignificantValueDigits, boolean keyed) { if (keys == null) { keys = DEFAULT_PERCENTS; } if (method == PercentilesMethod.TDIGEST) { return new TDigestPercentilesAggregator.Factory(aggregationName, valuesSourceConfig, keys, compression, keyed); } else if (method == PercentilesMethod.HDR) { return new HDRPercentilesAggregator.Factory(aggregationName, valuesSourceConfig, keys, numberOfSignificantValueDigits, keyed); } else { throw new AssertionError(); } }
Example #15
Source File: TDigestPercentileRanksAggregator.java From Elasticsearch with Apache License 2.0 | 5 votes |
public Factory(String name, ValuesSourceConfig<ValuesSource.Numeric> valuesSourceConfig, double[] values, double compression, boolean keyed) { super(name, InternalTDigestPercentiles.TYPE.name(), valuesSourceConfig); this.values = values; this.compression = compression; this.keyed = keyed; }
Example #16
Source File: TDigestPercentilesAggregator.java From Elasticsearch with Apache License 2.0 | 5 votes |
public Factory(String name, ValuesSourceConfig<ValuesSource.Numeric> valuesSourceConfig, double[] percents, double compression, boolean keyed) { super(name, InternalTDigestPercentiles.TYPE.name(), valuesSourceConfig); this.percents = percents; this.compression = compression; this.keyed = keyed; }
Example #17
Source File: HDRPercentilesAggregator.java From Elasticsearch with Apache License 2.0 | 5 votes |
public Factory(String name, ValuesSourceConfig<ValuesSource.Numeric> valuesSourceConfig, double[] percents, int numberOfSignificantValueDigits, boolean keyed) { super(name, InternalTDigestPercentiles.TYPE.name(), valuesSourceConfig); this.percents = percents; this.numberOfSignificantValueDigits = numberOfSignificantValueDigits; this.keyed = keyed; }
Example #18
Source File: HDRPercentileRanksAggregator.java From Elasticsearch with Apache License 2.0 | 5 votes |
public Factory(String name, ValuesSourceConfig<ValuesSource.Numeric> valuesSourceConfig, double[] values, int numberOfSignificantValueDigits, boolean keyed) { super(name, InternalHDRPercentiles.TYPE.name(), valuesSourceConfig); this.values = values; this.numberOfSignificantValueDigits = numberOfSignificantValueDigits; this.keyed = keyed; }
Example #19
Source File: PercentileRanksParser.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override protected AggregatorFactory buildFactory(SearchContext context, String aggregationName, ValuesSourceConfig<Numeric> valuesSourceConfig, double[] keys, PercentilesMethod method, Double compression, Integer numberOfSignificantValueDigits, boolean keyed) { if (keys == null) { throw new SearchParseException(context, "Missing token values in [" + aggregationName + "].", null); } if (method == PercentilesMethod.TDIGEST) { return new TDigestPercentileRanksAggregator.Factory(aggregationName, valuesSourceConfig, keys, compression, keyed); } else if (method == PercentilesMethod.HDR) { return new HDRPercentileRanksAggregator.Factory(aggregationName, valuesSourceConfig, keys, numberOfSignificantValueDigits, keyed); } else { throw new AssertionError(); } }
Example #20
Source File: TopKParser.java From elasticsearch-topk-plugin with Apache License 2.0 | 4 votes |
@Override public AggregatorFactory parse(String aggregationName, XContentParser parser, SearchContext context) throws IOException { ValuesSourceConfig<ValuesSource.Bytes> config = new ValuesSourceConfig<>(ValuesSource.Bytes.class); String field = null; Number size = null; Number capacity = 1000; 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 (token == XContentParser.Token.VALUE_STRING) { if ("field".equals(currentFieldName)) { field = parser.text(); } else { throw new SearchParseException(context, "Unknown key for a " + token + " in [" + aggregationName + "]: [" + currentFieldName + "]."); } } else if (token == XContentParser.Token.VALUE_NUMBER) { if ("size".equals(currentFieldName)) { size = parser.numberValue(); } else if ("capacity".equals(currentFieldName)) { capacity = parser.numberValue(); } else { throw new SearchParseException(context, "Unknown key for a " + token + " in [" + aggregationName + "]: [" + currentFieldName + "]."); } } else { throw new SearchParseException(context, "Unexpected token " + token + " in [" + aggregationName + "]."); } } if (field == null) { throw new SearchParseException(context, "Key 'field' cannot be null."); } if (size == null) { throw new SearchParseException(context, "Key 'size' cannot be null."); } FieldMapper<?> mapper = context.smartNameFieldMapper(field); if (mapper == null) { config.unmapped(true); return new TopKAggregator.Factory(aggregationName, config, size, capacity); } config.fieldContext(new FieldContext(field, context.fieldData().getForField(mapper), mapper)); return new TopKAggregator.Factory(aggregationName, config, size, capacity); }
Example #21
Source File: GeoHashGridParser.java From Elasticsearch with Apache License 2.0 | 4 votes |
public GeoGridFactory(String name, ValuesSourceConfig<ValuesSource.GeoPoint> config, int precision, int requiredSize, int shardSize) { super(name, InternalGeoHashGrid.TYPE.name(), config); this.precision = precision; this.requiredSize = requiredSize; this.shardSize = shardSize; }
Example #22
Source File: MissingAggregator.java From Elasticsearch with Apache License 2.0 | 4 votes |
public Factory(String name, ValuesSourceConfig valueSourceConfig) { super(name, InternalMissing.TYPE.name(), valueSourceConfig); }
Example #23
Source File: SamplerAggregator.java From Elasticsearch with Apache License 2.0 | 4 votes |
public DiversifiedFactory(String name, int shardSize, String executionHint, ValuesSourceConfig vsConfig, int maxDocsPerValue) { super(name, InternalSampler.TYPE.name(), vsConfig); this.shardSize = shardSize; this.maxDocsPerValue = maxDocsPerValue; this.executionHint = executionHint; }
Example #24
Source File: SamplerParser.java From Elasticsearch with Apache License 2.0 | 4 votes |
@Override public AggregatorFactory parse(String aggregationName, XContentParser parser, SearchContext context) throws IOException { XContentParser.Token token; String currentFieldName = null; String executionHint = null; int shardSize = DEFAULT_SHARD_SAMPLE_SIZE; int maxDocsPerValue = MAX_DOCS_PER_VALUE_DEFAULT; ValuesSourceParser vsParser = null; boolean diversityChoiceMade = false; vsParser = ValuesSourceParser.any(aggregationName, InternalSampler.TYPE, context).scriptable(true).formattable(false).build(); 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, SHARD_SIZE_FIELD)) { shardSize = parser.intValue(); } else if (context.parseFieldMatcher().match(currentFieldName, MAX_DOCS_PER_VALUE_FIELD)) { diversityChoiceMade = true; maxDocsPerValue = parser.intValue(); } else { throw new SearchParseException(context, "Unsupported property \"" + currentFieldName + "\" for aggregation \"" + aggregationName, parser.getTokenLocation()); } } else if (!vsParser.token(currentFieldName, token, parser)) { if (context.parseFieldMatcher().match(currentFieldName, EXECUTION_HINT_FIELD)) { executionHint = parser.text(); } else { throw new SearchParseException(context, "Unexpected token " + token + " in [" + aggregationName + "].", parser.getTokenLocation()); } } else { throw new SearchParseException(context, "Unsupported property \"" + currentFieldName + "\" for aggregation \"" + aggregationName, parser.getTokenLocation()); } } ValuesSourceConfig vsConfig = vsParser.config(); if (vsConfig.valid()) { return new SamplerAggregator.DiversifiedFactory(aggregationName, shardSize, executionHint, vsConfig, maxDocsPerValue); } else { if (diversityChoiceMade) { throw new SearchParseException(context, "Sampler aggregation has " + MAX_DOCS_PER_VALUE_FIELD.getPreferredName() + " setting but no \"field\" or \"script\" setting to provide values for aggregation \"" + aggregationName + "\"", parser.getTokenLocation()); } return new SamplerAggregator.Factory(aggregationName, shardSize); } }
Example #25
Source File: TopKAggregator.java From elasticsearch-topk-plugin with Apache License 2.0 | 4 votes |
public Factory(String name, ValuesSourceConfig<ValuesSource.Bytes> valueSourceConfig, Number size, Number capacity) { super(name, InternalTopK.TYPE.name(), valueSourceConfig); this.size = size; this.capacity = capacity; }
Example #26
Source File: MinAggregator.java From Elasticsearch with Apache License 2.0 | 4 votes |
public Factory(String name, ValuesSourceConfig<ValuesSource.Numeric> valuesSourceConfig) { super(name, InternalMin.TYPE.name(), valuesSourceConfig); }
Example #27
Source File: ChildrenParser.java From Elasticsearch with Apache License 2.0 | 4 votes |
@Override public AggregatorFactory parse(String aggregationName, XContentParser parser, SearchContext context) throws IOException { String childType = null; 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 (token == XContentParser.Token.VALUE_STRING) { if ("type".equals(currentFieldName)) { childType = parser.text(); } 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 (childType == null) { throw new SearchParseException(context, "Missing [child_type] field for children aggregation [" + aggregationName + "]", parser.getTokenLocation()); } ValuesSourceConfig<ValuesSource.Bytes.WithOrdinals.ParentChild> config = new ValuesSourceConfig<>(ValuesSource.Bytes.WithOrdinals.ParentChild.class); DocumentMapper childDocMapper = context.mapperService().documentMapper(childType); String parentType = null; Query parentFilter = null; Query childFilter = null; if (childDocMapper != null) { ParentFieldMapper parentFieldMapper = childDocMapper.parentFieldMapper(); if (!parentFieldMapper.active()) { throw new SearchParseException(context, "[children] no [_parent] field not configured that points to a parent type", parser.getTokenLocation()); } parentType = parentFieldMapper.type(); DocumentMapper parentDocMapper = context.mapperService().documentMapper(parentType); if (parentDocMapper != null) { // TODO: use the query API parentFilter = parentDocMapper.typeFilter(); childFilter = childDocMapper.typeFilter(); ParentChildIndexFieldData parentChildIndexFieldData = context.fieldData().getForField(parentFieldMapper.fieldType()); config.fieldContext(new FieldContext(parentFieldMapper.fieldType().names().indexName(), parentChildIndexFieldData, parentFieldMapper.fieldType())); } else { config.unmapped(true); } } else { config.unmapped(true); } return new ParentToChildrenAggregator.Factory(aggregationName, config, parentType, parentFilter, childFilter); }
Example #28
Source File: RangeAggregator.java From Elasticsearch with Apache License 2.0 | 4 votes |
public Factory(String name, ValuesSourceConfig<ValuesSource.Numeric> valueSourceConfig, InternalRange.Factory rangeFactory, List<Range> ranges, boolean keyed) { super(name, rangeFactory.type(), valueSourceConfig); this.rangeFactory = rangeFactory; this.ranges = ranges; this.keyed = keyed; }
Example #29
Source File: AbstractPercentilesParser.java From Elasticsearch with Apache License 2.0 | 4 votes |
protected abstract AggregatorFactory buildFactory(SearchContext context, String aggregationName, ValuesSourceConfig<Numeric> config, double[] cdfValues, PercentilesMethod method, Double compression, Integer numberOfSignificantValueDigits, boolean keyed);
Example #30
Source File: CardinalityAggregatorFactory.java From Elasticsearch with Apache License 2.0 | 4 votes |
CardinalityAggregatorFactory(String name, ValuesSourceConfig config, long precisionThreshold) { super(name, InternalCardinality.TYPE.name(), config); this.precisionThreshold = precisionThreshold; }