@Override protected CompositeValuesSourceConfig innerBuild(SearchContext context, ValuesSourceConfig<?> config) throws IOException { ValuesSource orig = config.toValuesSource(context.getQueryShardContext()); if (orig == null) { orig = ValuesSource.Numeric.EMPTY; } if (orig instanceof ValuesSource.Numeric) { ValuesSource.Numeric numeric = (ValuesSource.Numeric) orig; final HistogramValuesSource vs = new HistogramValuesSource(numeric, interval); final MappedFieldType fieldType = config.fieldContext() != null ? config.fieldContext().fieldType() : null; return new CompositeValuesSourceConfig(name, fieldType, vs, config.format(), order(), missingBucket(), missing()); } else { throw new IllegalArgumentException("invalid source, expected numeric, got " + orig.getClass().getSimpleName()); } } }
private ValuesSource.GeoPoint geoPointField() throws IOException { if (!(fieldContext().indexFieldData() instanceof IndexGeoPointFieldData)) { throw new IllegalArgumentException("Expected geo_point type on field [" + fieldContext().field() + "], but got [" + fieldContext().fieldType().typeName() + "]"); } return new ValuesSource.GeoPoint.Fielddata((IndexGeoPointFieldData) fieldContext().indexFieldData()); } }
MappedFieldType fieldType = config.fieldContext().fieldType(); if (fieldType == null || fieldType.indexOptions() == IndexOptions.NONE) { return null;
@Override protected CompositeValuesSourceConfig innerBuild(SearchContext context, ValuesSourceConfig<?> config) throws IOException { Rounding rounding = createRounding(); ValuesSource orig = config.toValuesSource(context.getQueryShardContext()); if (orig == null) { orig = ValuesSource.Numeric.EMPTY; } if (orig instanceof ValuesSource.Numeric) { ValuesSource.Numeric numeric = (ValuesSource.Numeric) orig; RoundingValuesSource vs = new RoundingValuesSource(numeric, rounding); // is specified in the builder. final DocValueFormat docValueFormat = format() == null ? DocValueFormat.RAW : config.format(); final MappedFieldType fieldType = config.fieldContext() != null ? config.fieldContext().fieldType() : null; return new CompositeValuesSourceConfig(name, fieldType, vs, docValueFormat, order(), missingBucket(), missing()); } else { throw new IllegalArgumentException("invalid source, expected numeric, got " + orig.getClass().getSimpleName()); } } }
private ValuesSource.Numeric numericField() throws IOException { if (!(fieldContext().indexFieldData() instanceof IndexNumericFieldData)) { throw new IllegalArgumentException("Expected numeric type on field [" + fieldContext().field() + "], but got [" + fieldContext().fieldType().typeName() + "]"); } ValuesSource.Numeric dataSource = new ValuesSource.Numeric.FieldData((IndexNumericFieldData)fieldContext().indexFieldData()); if (script() != null) { dataSource = new ValuesSource.Numeric.WithScript(dataSource, script()); } return dataSource; }
@Override protected CompositeValuesSourceConfig innerBuild(SearchContext context, ValuesSourceConfig<?> config) throws IOException { ValuesSource vs = config.toValuesSource(context.getQueryShardContext()); if (vs == null) { vs = ValuesSource.Numeric.EMPTY; } final MappedFieldType fieldType = config.fieldContext() != null ? config.fieldContext().fieldType() : null; final DocValueFormat format; if (format() == null && fieldType instanceof DateFieldMapper.DateFieldType) { // defaults to the raw format on date fields (preserve timestamp as longs). format = DocValueFormat.RAW; } else { format = config.format(); } return new CompositeValuesSourceConfig(name, fieldType, vs, format, order(), missingBucket(), missing()); } }
public SignificantTermsAggregatorFactory(String name, ValuesSourceConfig<ValuesSource> config, IncludeExclude includeExclude, String executionHint, QueryBuilder filterBuilder, TermsAggregator.BucketCountThresholds bucketCountThresholds, SignificanceHeuristic significanceHeuristic, SearchContext context, AggregatorFactory<?> parent, AggregatorFactories.Builder subFactoriesBuilder, Map<String, Object> metaData) throws IOException { super(name, config, context, parent, subFactoriesBuilder, metaData); if (!config.unmapped()) { this.fieldType = config.fieldContext().fieldType(); this.indexedFieldName = fieldType.name(); } this.includeExclude = includeExclude; this.executionHint = executionHint; this.filter = filterBuilder == null ? null : filterBuilder.toFilter(context.getQueryShardContext()); IndexSearcher searcher = context.searcher(); this.supersetNumDocs = filter == null // Important - need to use the doc count that includes deleted docs // or we have this issue: https://github.com/elastic/elasticsearch/issues/7951 ? searcher.getIndexReader().maxDoc() : searcher.count(filter); this.bucketCountThresholds = bucketCountThresholds; this.significanceHeuristic = significanceHeuristic; }
private ValuesSource.GeoPoint geoPointField(ValuesSourceConfig<?> config) throws IOException { if (!(config.fieldContext.indexFieldData() instanceof IndexGeoPointFieldData)) { throw new IllegalArgumentException("Expected geo_point type on field [" + config.fieldContext.field() + "], but got [" + config.fieldContext.fieldType().typeName() + "]"); } return new ValuesSource.GeoPoint.Fielddata((IndexGeoPointFieldData) config.fieldContext.indexFieldData()); }
private ValuesSource.Numeric numericField(ValuesSourceConfig<?> config) throws IOException { if (!(config.fieldContext.indexFieldData() instanceof IndexNumericFieldData)) { throw new IllegalArgumentException("Expected numeric type on field [" + config.fieldContext.field() + "], but got [" + config.fieldContext.fieldType().typeName() + "]"); } ValuesSource.Numeric dataSource = new ValuesSource.Numeric.FieldData((IndexNumericFieldData) config.fieldContext.indexFieldData()); if (config.script != null) { dataSource = new ValuesSource.Numeric.WithScript(dataSource, config.script); } return dataSource; }
@Override protected CompositeValuesSourceConfig innerBuild(SearchContext context, ValuesSourceConfig<?> config) throws IOException { ValuesSource orig = config.toValuesSource(context.getQueryShardContext()); if (orig == null) { orig = ValuesSource.Numeric.EMPTY; } if (orig instanceof ValuesSource.Numeric) { ValuesSource.Numeric numeric = (ValuesSource.Numeric) orig; final HistogramValuesSource vs = new HistogramValuesSource(numeric, interval); final MappedFieldType fieldType = config.fieldContext() != null ? config.fieldContext().fieldType() : null; return new CompositeValuesSourceConfig(name, fieldType, vs, config.format(), order(), missingBucket(), missing()); } else { throw new IllegalArgumentException("invalid source, expected numeric, got " + orig.getClass().getSimpleName()); } } }
@Override protected CompositeValuesSourceConfig innerBuild(SearchContext context, ValuesSourceConfig<?> config) throws IOException { ValuesSource orig = config.toValuesSource(context.getQueryShardContext()); if (orig == null) { orig = ValuesSource.Numeric.EMPTY; } if (orig instanceof ValuesSource.Numeric) { ValuesSource.Numeric numeric = (ValuesSource.Numeric) orig; final HistogramValuesSource vs = new HistogramValuesSource(numeric, interval); final MappedFieldType fieldType = config.fieldContext() != null ? config.fieldContext().fieldType() : null; return new CompositeValuesSourceConfig(name, fieldType, vs, config.format(), order(), missingBucket(), missing()); } else { throw new IllegalArgumentException("invalid source, expected numeric, got " + orig.getClass().getSimpleName()); } } }
private ValuesSource.GeoPoint geoPointField() throws IOException { if (!(fieldContext().indexFieldData() instanceof IndexGeoPointFieldData)) { throw new IllegalArgumentException("Expected geo_point type on field [" + fieldContext().field() + "], but got [" + fieldContext().fieldType().typeName() + "]"); } return new ValuesSource.GeoPoint.Fielddata((IndexGeoPointFieldData) fieldContext().indexFieldData()); } }
private ValuesSource.GeoPoint geoPointField() throws IOException { if (!(fieldContext().indexFieldData() instanceof IndexGeoPointFieldData)) { throw new IllegalArgumentException("Expected geo_point type on field [" + fieldContext().field() + "], but got [" + fieldContext().fieldType().typeName() + "]"); } return new ValuesSource.GeoPoint.Fielddata((IndexGeoPointFieldData) fieldContext().indexFieldData()); } }
private ValuesSource.GeoPoint geoPointField() throws IOException { if (!(fieldContext().indexFieldData() instanceof IndexGeoPointFieldData)) { throw new IllegalArgumentException("Expected geo_point type on field [" + fieldContext().field() + "], but got [" + fieldContext().fieldType().typeName() + "]"); } return new ValuesSource.GeoPoint.Fielddata((IndexGeoPointFieldData) fieldContext().indexFieldData()); } }
@Override protected CompositeValuesSourceConfig innerBuild(SearchContext context, ValuesSourceConfig<?> config) throws IOException { Rounding rounding = createRounding(); ValuesSource orig = config.toValuesSource(context.getQueryShardContext()); if (orig == null) { orig = ValuesSource.Numeric.EMPTY; } if (orig instanceof ValuesSource.Numeric) { ValuesSource.Numeric numeric = (ValuesSource.Numeric) orig; RoundingValuesSource vs = new RoundingValuesSource(numeric, rounding); // is specified in the builder. final DocValueFormat docValueFormat = format() == null ? DocValueFormat.RAW : config.format(); final MappedFieldType fieldType = config.fieldContext() != null ? config.fieldContext().fieldType() : null; return new CompositeValuesSourceConfig(name, fieldType, vs, docValueFormat, order(), missingBucket(), missing()); } else { throw new IllegalArgumentException("invalid source, expected numeric, got " + orig.getClass().getSimpleName()); } } }
private ValuesSource.Numeric numericField() throws IOException { if (!(fieldContext().indexFieldData() instanceof IndexNumericFieldData)) { throw new IllegalArgumentException("Expected numeric type on field [" + fieldContext().field() + "], but got [" + fieldContext().fieldType().typeName() + "]"); } ValuesSource.Numeric dataSource = new ValuesSource.Numeric.FieldData((IndexNumericFieldData)fieldContext().indexFieldData()); if (script() != null) { dataSource = new ValuesSource.Numeric.WithScript(dataSource, script()); } return dataSource; }
private ValuesSource.Numeric numericField() throws IOException { if (!(fieldContext().indexFieldData() instanceof IndexNumericFieldData)) { throw new IllegalArgumentException("Expected numeric type on field [" + fieldContext().field() + "], but got [" + fieldContext().fieldType().typeName() + "]"); } ValuesSource.Numeric dataSource = new ValuesSource.Numeric.FieldData((IndexNumericFieldData)fieldContext().indexFieldData()); if (script() != null) { dataSource = new ValuesSource.Numeric.WithScript(dataSource, script()); } return dataSource; }
private ValuesSource.Numeric numericField() throws IOException { if (!(fieldContext().indexFieldData() instanceof IndexNumericFieldData)) { throw new IllegalArgumentException("Expected numeric type on field [" + fieldContext().field() + "], but got [" + fieldContext().fieldType().typeName() + "]"); } ValuesSource.Numeric dataSource = new ValuesSource.Numeric.FieldData((IndexNumericFieldData)fieldContext().indexFieldData()); if (script() != null) { dataSource = new ValuesSource.Numeric.WithScript(dataSource, script()); } return dataSource; }
@Override protected CompositeValuesSourceConfig innerBuild(SearchContext context, ValuesSourceConfig<?> config) throws IOException { ValuesSource vs = config.toValuesSource(context.getQueryShardContext()); if (vs == null) { vs = ValuesSource.Numeric.EMPTY; } final MappedFieldType fieldType = config.fieldContext() != null ? config.fieldContext().fieldType() : null; final DocValueFormat format; if (format() == null && fieldType instanceof DateFieldMapper.DateFieldType) { // defaults to the raw format on date fields (preserve timestamp as longs). format = DocValueFormat.RAW; } else { format = config.format(); } return new CompositeValuesSourceConfig(name, fieldType, vs, format, order(), missingBucket(), missing()); } }
@Override protected CompositeValuesSourceConfig innerBuild(SearchContext context, ValuesSourceConfig<?> config) throws IOException { ValuesSource vs = config.toValuesSource(context.getQueryShardContext()); if (vs == null) { vs = ValuesSource.Numeric.EMPTY; } final MappedFieldType fieldType = config.fieldContext() != null ? config.fieldContext().fieldType() : null; final DocValueFormat format; if (format() == null && fieldType instanceof DateFieldMapper.DateFieldType) { // defaults to the raw format on date fields (preserve timestamp as longs). format = DocValueFormat.RAW; } else { format = config.format(); } return new CompositeValuesSourceConfig(name, fieldType, vs, format, order(), missingBucket(), missing()); } }