diff --git a/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/RankFeatureFieldMapper.java b/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/RankFeatureFieldMapper.java index 925e633d9dbab..1ad4aff24977b 100644 --- a/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/RankFeatureFieldMapper.java +++ b/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/RankFeatureFieldMapper.java @@ -114,11 +114,11 @@ public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName, S } @Override - public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) { + public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup searchLookup, String format) { if (format != null) { throw new IllegalArgumentException("Field [" + name() + "] of type [" + typeName() + "] doesn't support formats."); } - return new SourceValueFetcher(name(), mapperService) { + return new SourceValueFetcher(name(), context) { @Override protected Float parseSourceValue(Object value) { return objectToFloat(value); diff --git a/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/RankFeatureMetaFieldMapper.java b/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/RankFeatureMetaFieldMapper.java index 1227c498130ac..f09fd9f740ee9 100644 --- a/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/RankFeatureMetaFieldMapper.java +++ b/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/RankFeatureMetaFieldMapper.java @@ -52,7 +52,7 @@ public String typeName() { } @Override - public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) { + public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup searchLookup, String format) { throw new UnsupportedOperationException("Cannot fetch values for internal field [" + typeName() + "]."); } diff --git a/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/RankFeaturesFieldMapper.java b/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/RankFeaturesFieldMapper.java index 9bf122bcb915d..780aa26f742dc 100644 --- a/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/RankFeaturesFieldMapper.java +++ b/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/RankFeaturesFieldMapper.java @@ -87,8 +87,8 @@ public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName, S } @Override - public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) { - return SourceValueFetcher.identity(name(), mapperService, format); + public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup searchLookup, String format) { + return SourceValueFetcher.identity(name(), context, format); } @Override diff --git a/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/ScaledFloatFieldMapper.java b/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/ScaledFloatFieldMapper.java index 13f222e99d88c..72060629deea0 100644 --- a/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/ScaledFloatFieldMapper.java +++ b/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/ScaledFloatFieldMapper.java @@ -207,11 +207,11 @@ public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName, S } @Override - public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) { + public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup searchLookup, String format) { if (format != null) { throw new IllegalArgumentException("Field [" + name() + "] of type [" + typeName() + "] doesn't support formats."); } - return new SourceValueFetcher(name(), mapperService) { + return new SourceValueFetcher(name(), context) { @Override protected Double parseSourceValue(Object value) { double doubleValue; diff --git a/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/SearchAsYouTypeFieldMapper.java b/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/SearchAsYouTypeFieldMapper.java index a915b49478f18..ae1ceca69fc56 100644 --- a/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/SearchAsYouTypeFieldMapper.java +++ b/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/SearchAsYouTypeFieldMapper.java @@ -264,8 +264,8 @@ private ShingleFieldType shingleFieldForPositions(int positions) { } @Override - public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) { - return SourceValueFetcher.toString(name(), mapperService, format); + public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup searchLookup, String format) { + return SourceValueFetcher.toString(name(), context, format); } @Override @@ -375,10 +375,10 @@ public Query prefixQuery(String value, MultiTermQuery.RewriteMethod method, bool } @Override - public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) { + public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup searchLookup, String format) { // Because this internal field is modelled as a multi-field, SourceValueFetcher will look up its // parent field in _source. So we don't need to use the parent field name here. - return SourceValueFetcher.toString(name(), mapperService, format); + return SourceValueFetcher.toString(name(), context, format); } @Override @@ -487,10 +487,10 @@ void setPrefixFieldType(PrefixFieldType prefixFieldType) { } @Override - public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) { + public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup searchLookup, String format) { // Because this internal field is modelled as a multi-field, SourceValueFetcher will look up its // parent field in _source. So we don't need to use the parent field name here. - return SourceValueFetcher.toString(name(), mapperService, format); + return SourceValueFetcher.toString(name(), context, format); } @Override diff --git a/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/TokenCountFieldMapper.java b/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/TokenCountFieldMapper.java index 069ea93cd3a8f..3758bcfa83a18 100644 --- a/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/TokenCountFieldMapper.java +++ b/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/TokenCountFieldMapper.java @@ -23,6 +23,7 @@ import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute; import org.elasticsearch.index.analysis.NamedAnalyzer; +import org.elasticsearch.index.query.QueryShardContext; import org.elasticsearch.search.lookup.SearchLookup; import java.io.IOException; @@ -92,7 +93,7 @@ static class TokenCountFieldType extends NumberFieldMapper.NumberFieldType { } @Override - public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) { + public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup searchLookup, String format) { if (hasDocValues() == false) { return lookup -> List.of(); } diff --git a/modules/parent-join/src/main/java/org/elasticsearch/join/mapper/MetaJoinFieldMapper.java b/modules/parent-join/src/main/java/org/elasticsearch/join/mapper/MetaJoinFieldMapper.java index 2ee676a78110f..34859d4d63773 100644 --- a/modules/parent-join/src/main/java/org/elasticsearch/join/mapper/MetaJoinFieldMapper.java +++ b/modules/parent-join/src/main/java/org/elasticsearch/join/mapper/MetaJoinFieldMapper.java @@ -21,7 +21,6 @@ import org.apache.lucene.search.Query; import org.elasticsearch.index.fielddata.IndexFieldData; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.MetadataFieldMapper; import org.elasticsearch.index.mapper.ParseContext; import org.elasticsearch.index.mapper.StringFieldType; @@ -66,7 +65,7 @@ public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName, S } @Override - public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) { + public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup searchLookup, String format) { throw new UnsupportedOperationException("Cannot fetch values for metadata field [" + NAME + "]."); } diff --git a/modules/parent-join/src/main/java/org/elasticsearch/join/mapper/ParentIdFieldMapper.java b/modules/parent-join/src/main/java/org/elasticsearch/join/mapper/ParentIdFieldMapper.java index fc5df42311782..2392ef89e0069 100644 --- a/modules/parent-join/src/main/java/org/elasticsearch/join/mapper/ParentIdFieldMapper.java +++ b/modules/parent-join/src/main/java/org/elasticsearch/join/mapper/ParentIdFieldMapper.java @@ -28,11 +28,11 @@ import org.elasticsearch.index.fielddata.IndexFieldData; import org.elasticsearch.index.fielddata.plain.SortedSetOrdinalsIndexFieldData; import org.elasticsearch.index.mapper.FieldMapper; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.ParseContext; import org.elasticsearch.index.mapper.StringFieldType; import org.elasticsearch.index.mapper.TextSearchInfo; import org.elasticsearch.index.mapper.ValueFetcher; +import org.elasticsearch.index.query.QueryShardContext; import org.elasticsearch.search.aggregations.support.CoreValuesSourceType; import org.elasticsearch.search.lookup.SearchLookup; @@ -76,7 +76,7 @@ public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName, S } @Override - public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) { + public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup searchLookup, String format) { throw new UnsupportedOperationException("Cannot fetch values for internal field [" + typeName() + "]."); } diff --git a/modules/parent-join/src/main/java/org/elasticsearch/join/mapper/ParentJoinFieldMapper.java b/modules/parent-join/src/main/java/org/elasticsearch/join/mapper/ParentJoinFieldMapper.java index 9b94c27bd7914..68989bbbf60e9 100644 --- a/modules/parent-join/src/main/java/org/elasticsearch/join/mapper/ParentJoinFieldMapper.java +++ b/modules/parent-join/src/main/java/org/elasticsearch/join/mapper/ParentJoinFieldMapper.java @@ -34,12 +34,12 @@ import org.elasticsearch.index.mapper.FieldMapper; import org.elasticsearch.index.mapper.MappedFieldType; import org.elasticsearch.index.mapper.Mapper; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.ParseContext; import org.elasticsearch.index.mapper.SourceValueFetcher; import org.elasticsearch.index.mapper.StringFieldType; import org.elasticsearch.index.mapper.TextSearchInfo; import org.elasticsearch.index.mapper.ValueFetcher; +import org.elasticsearch.index.query.QueryShardContext; import org.elasticsearch.search.aggregations.support.CoreValuesSourceType; import org.elasticsearch.search.lookup.SearchLookup; @@ -163,8 +163,8 @@ public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName, S } @Override - public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) { - return SourceValueFetcher.identity(name(), mapperService, format); + public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup searchLookup, String format) { + return SourceValueFetcher.identity(name(), context, format); } @Override diff --git a/modules/percolator/src/main/java/org/elasticsearch/percolator/PercolatorFieldMapper.java b/modules/percolator/src/main/java/org/elasticsearch/percolator/PercolatorFieldMapper.java index 658e847d1f5e9..c17578fdb989f 100644 --- a/modules/percolator/src/main/java/org/elasticsearch/percolator/PercolatorFieldMapper.java +++ b/modules/percolator/src/main/java/org/elasticsearch/percolator/PercolatorFieldMapper.java @@ -59,7 +59,6 @@ import org.elasticsearch.index.mapper.MappedFieldType; import org.elasticsearch.index.mapper.Mapper; import org.elasticsearch.index.mapper.MapperParsingException; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.NumberFieldMapper; import org.elasticsearch.index.mapper.ParseContext; import org.elasticsearch.index.mapper.RangeFieldMapper; @@ -217,8 +216,8 @@ public Query termQuery(Object value, QueryShardContext context) { } @Override - public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) { - return SourceValueFetcher.identity(name(), mapperService, format); + public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup searchLookup, String format) { + return SourceValueFetcher.identity(name(), context, format); } Query percolateQuery(String name, PercolateQuery.QueryStore queryStore, List documents, diff --git a/plugins/analysis-icu/src/main/java/org/elasticsearch/index/mapper/ICUCollationKeywordFieldMapper.java b/plugins/analysis-icu/src/main/java/org/elasticsearch/index/mapper/ICUCollationKeywordFieldMapper.java index 15c4b67e8c903..ff961784fabda 100644 --- a/plugins/analysis-icu/src/main/java/org/elasticsearch/index/mapper/ICUCollationKeywordFieldMapper.java +++ b/plugins/analysis-icu/src/main/java/org/elasticsearch/index/mapper/ICUCollationKeywordFieldMapper.java @@ -82,12 +82,12 @@ public String typeName() { } @Override - public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) { + public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup searchLookup, String format) { if (format != null) { throw new IllegalArgumentException("Field [" + name() + "] of type [" + typeName() + "] doesn't support formats."); } - return new SourceValueFetcher(name(), mapperService, nullValue) { + return new SourceValueFetcher(name(), context, nullValue) { @Override protected String parseSourceValue(Object value) { String keywordValue = value.toString(); diff --git a/plugins/mapper-murmur3/src/main/java/org/elasticsearch/index/mapper/murmur3/Murmur3FieldMapper.java b/plugins/mapper-murmur3/src/main/java/org/elasticsearch/index/mapper/murmur3/Murmur3FieldMapper.java index d96f48e508663..d35df1372988f 100644 --- a/plugins/mapper-murmur3/src/main/java/org/elasticsearch/index/mapper/murmur3/Murmur3FieldMapper.java +++ b/plugins/mapper-murmur3/src/main/java/org/elasticsearch/index/mapper/murmur3/Murmur3FieldMapper.java @@ -31,7 +31,6 @@ import org.elasticsearch.index.fielddata.plain.SortedNumericIndexFieldData; import org.elasticsearch.index.mapper.FieldMapper; import org.elasticsearch.index.mapper.MappedFieldType; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.ParseContext; import org.elasticsearch.index.mapper.SourceValueFetcher; import org.elasticsearch.index.mapper.TextSearchInfo; @@ -104,8 +103,8 @@ public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName, S } @Override - public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) { - return SourceValueFetcher.toString(name(), mapperService, format); + public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup searchLookup, String format) { + return SourceValueFetcher.toString(name(), context, format); } @Override diff --git a/server/src/main/java/org/elasticsearch/index/mapper/AbstractGeometryFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/AbstractGeometryFieldMapper.java index 5a7d59d2879ac..ef70e836fd773 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/AbstractGeometryFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/AbstractGeometryFieldMapper.java @@ -123,19 +123,19 @@ public final Query termQuery(Object value, QueryShardContext context) { } @Override - public final ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) { + public final ValueFetcher valueFetcher(QueryShardContext context, SearchLookup searchLookup, String format) { String geoFormat = format != null ? format : GeoJsonGeometryFormat.NAME; Function valueParser = value -> geometryParser.parseAndFormatObject(value, geoFormat); if (parsesArrayValue) { - return new ArraySourceValueFetcher(name(), mapperService) { + return new ArraySourceValueFetcher(name(), context) { @Override protected Object parseSourceValue(Object value) { return valueParser.apply(value); } }; } else { - return new SourceValueFetcher(name(), mapperService) { + return new SourceValueFetcher(name(), context) { @Override protected Object parseSourceValue(Object value) { return valueParser.apply(value); diff --git a/server/src/main/java/org/elasticsearch/index/mapper/ArraySourceValueFetcher.java b/server/src/main/java/org/elasticsearch/index/mapper/ArraySourceValueFetcher.java index 28fd39b52b727..e9decf9656722 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/ArraySourceValueFetcher.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/ArraySourceValueFetcher.java @@ -20,6 +20,7 @@ package org.elasticsearch.index.mapper; import org.elasticsearch.common.Nullable; +import org.elasticsearch.index.query.QueryShardContext; import org.elasticsearch.search.lookup.SourceLookup; import java.util.ArrayList; @@ -38,17 +39,17 @@ public abstract class ArraySourceValueFetcher implements ValueFetcher { private final Set sourcePaths; private final @Nullable Object nullValue; - public ArraySourceValueFetcher(String fieldName, MapperService mapperService) { - this(fieldName, mapperService, null); + public ArraySourceValueFetcher(String fieldName, QueryShardContext context) { + this(fieldName, context, null); } /** * @param fieldName The name of the field. - * @param mapperService A mapper service. + * @param context The query shard context * @param nullValue A optional substitute value if the _source value is 'null'. */ - public ArraySourceValueFetcher(String fieldName, MapperService mapperService, Object nullValue) { - this.sourcePaths = mapperService.sourcePath(fieldName); + public ArraySourceValueFetcher(String fieldName, QueryShardContext context, Object nullValue) { + this.sourcePaths = context.sourcePath(fieldName); this.nullValue = nullValue; } diff --git a/server/src/main/java/org/elasticsearch/index/mapper/BinaryFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/BinaryFieldMapper.java index 15055854348dc..cc5aa141172d6 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/BinaryFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/BinaryFieldMapper.java @@ -97,8 +97,8 @@ public String typeName() { } @Override - public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) { - return SourceValueFetcher.identity(name(), mapperService, format); + public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup searchLookup, String format) { + return SourceValueFetcher.identity(name(), context, format); } @Override diff --git a/server/src/main/java/org/elasticsearch/index/mapper/BooleanFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/BooleanFieldMapper.java index 082355a76348e..bf10f9f16dcee 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/BooleanFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/BooleanFieldMapper.java @@ -127,12 +127,12 @@ public String typeName() { } @Override - public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) { + public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup searchLookup, String format) { if (format != null) { throw new IllegalArgumentException("Field [" + name() + "] of type [" + typeName() + "] doesn't support formats."); } - return new SourceValueFetcher(name(), mapperService, nullValue) { + return new SourceValueFetcher(name(), context, nullValue) { @Override protected Boolean parseSourceValue(Object value) { if (value instanceof Boolean) { diff --git a/server/src/main/java/org/elasticsearch/index/mapper/CompletionFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/CompletionFieldMapper.java index 7a7eb887de1c5..1c007fb6f4065 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/CompletionFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/CompletionFieldMapper.java @@ -41,6 +41,7 @@ import org.elasticsearch.common.xcontent.XContentParser.Token; import org.elasticsearch.index.analysis.AnalyzerScope; import org.elasticsearch.index.analysis.NamedAnalyzer; +import org.elasticsearch.index.query.QueryShardContext; import org.elasticsearch.search.lookup.SearchLookup; import org.elasticsearch.search.suggest.completion.CompletionSuggester; import org.elasticsearch.search.suggest.completion.context.ContextMapping; @@ -306,12 +307,12 @@ public String typeName() { } @Override - public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) { + public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup searchLookup, String format) { if (format != null) { throw new IllegalArgumentException("Field [" + name() + "] of type [" + typeName() + "] doesn't support formats."); } - return new ArraySourceValueFetcher(name(), mapperService) { + return new ArraySourceValueFetcher(name(), context) { @Override protected List parseSourceValue(Object value) { if (value instanceof List) { diff --git a/server/src/main/java/org/elasticsearch/index/mapper/DateFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/DateFieldMapper.java index f188563d05a1b..948ea6de5cc53 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/DateFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/DateFieldMapper.java @@ -319,13 +319,13 @@ public long parse(String value) { } @Override - public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) { + public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup searchLookup, String format) { DateFormatter defaultFormatter = dateTimeFormatter(); DateFormatter formatter = format != null ? DateFormatter.forPattern(format).withLocale(defaultFormatter.locale()) : defaultFormatter; - return new SourceValueFetcher(name(), mapperService, nullValue) { + return new SourceValueFetcher(name(), context, nullValue) { @Override public String parseSourceValue(Object value) { String date = value.toString(); diff --git a/server/src/main/java/org/elasticsearch/index/mapper/FieldNamesFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/FieldNamesFieldMapper.java index 53021c4c7660f..07541ac6360da 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/FieldNamesFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/FieldNamesFieldMapper.java @@ -131,7 +131,7 @@ public boolean isEnabled() { } @Override - public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup lookup, String format) { + public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup lookup, String format) { throw new UnsupportedOperationException("Cannot fetch values for internal field [" + name() + "]."); } diff --git a/server/src/main/java/org/elasticsearch/index/mapper/IdFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/IdFieldMapper.java index 23a8d185f9f1b..131817b0d4f1c 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/IdFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/IdFieldMapper.java @@ -120,7 +120,7 @@ public boolean isSearchable() { } @Override - public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup lookup, String format) { + public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup lookup, String format) { throw new UnsupportedOperationException("Cannot fetch values for internal field [" + name() + "]."); } diff --git a/server/src/main/java/org/elasticsearch/index/mapper/IgnoredFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/IgnoredFieldMapper.java index 612944e6047ae..24d86e01abfaa 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/IgnoredFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/IgnoredFieldMapper.java @@ -77,7 +77,7 @@ public Query existsQuery(QueryShardContext context) { } @Override - public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup lookup, String format) { + public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup lookup, String format) { throw new UnsupportedOperationException("Cannot fetch values for internal field [" + name() + "]."); } } diff --git a/server/src/main/java/org/elasticsearch/index/mapper/IndexFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/IndexFieldMapper.java index af594c30e7f97..66c177918b456 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/IndexFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/IndexFieldMapper.java @@ -73,7 +73,7 @@ public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName, S } @Override - public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) { + public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup searchLookup, String format) { throw new UnsupportedOperationException("Cannot fetch values for internal field [" + name() + "]."); } } diff --git a/server/src/main/java/org/elasticsearch/index/mapper/IpFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/IpFieldMapper.java index 52af5ca20b722..1b9918fbd9cf3 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/IpFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/IpFieldMapper.java @@ -158,11 +158,11 @@ private static InetAddress parse(Object value) { } @Override - public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) { + public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup searchLookup, String format) { if (format != null) { throw new IllegalArgumentException("Field [" + name() + "] of type [" + typeName() + "] doesn't support formats."); } - return new SourceValueFetcher(name(), mapperService, nullValue) { + return new SourceValueFetcher(name(), context, nullValue) { @Override protected Object parseSourceValue(Object value) { InetAddress address; diff --git a/server/src/main/java/org/elasticsearch/index/mapper/KeywordFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/KeywordFieldMapper.java index c66fde9ccbf2e..293360b7cb81e 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/KeywordFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/KeywordFieldMapper.java @@ -32,6 +32,7 @@ import org.elasticsearch.index.analysis.NamedAnalyzer; import org.elasticsearch.index.fielddata.IndexFieldData; import org.elasticsearch.index.fielddata.plain.SortedSetOrdinalsIndexFieldData; +import org.elasticsearch.index.query.QueryShardContext; import org.elasticsearch.index.similarity.SimilarityProvider; import org.elasticsearch.search.aggregations.support.CoreValuesSourceType; import org.elasticsearch.search.lookup.SearchLookup; @@ -235,12 +236,12 @@ public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName, S } @Override - public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) { + public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup searchLookup, String format) { if (format != null) { throw new IllegalArgumentException("Field [" + name() + "] of type [" + typeName() + "] doesn't support formats."); } - return new SourceValueFetcher(name(), mapperService, nullValue) { + return new SourceValueFetcher(name(), context, nullValue) { @Override protected String parseSourceValue(Object value) { String keywordValue = value.toString(); diff --git a/server/src/main/java/org/elasticsearch/index/mapper/MappedFieldType.java b/server/src/main/java/org/elasticsearch/index/mapper/MappedFieldType.java index 213c7ee001063..db80fcae21dd1 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/MappedFieldType.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/MappedFieldType.java @@ -105,7 +105,7 @@ public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName, S * for metadata fields, field types should not throw {@link UnsupportedOperationException} since this * could cause a search retrieving multiple fields (like "fields": ["*"]) to fail. */ - public abstract ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, @Nullable String format); + public abstract ValueFetcher valueFetcher(QueryShardContext context, SearchLookup searchLookup, @Nullable String format); /** Returns the name of this type, as would be specified in mapping properties */ public abstract String typeName(); diff --git a/server/src/main/java/org/elasticsearch/index/mapper/NestedPathFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/NestedPathFieldMapper.java index a8f0298e76aa9..ce92d017eb302 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/NestedPathFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/NestedPathFieldMapper.java @@ -89,7 +89,7 @@ public Query existsQuery(QueryShardContext context) { } @Override - public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup lookup, String format) { + public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup lookup, String format) { throw new UnsupportedOperationException("Cannot fetch values for internal field [" + name() + "]."); } } diff --git a/server/src/main/java/org/elasticsearch/index/mapper/NumberFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/NumberFieldMapper.java index e5516d03a57ee..f180caad813cb 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/NumberFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/NumberFieldMapper.java @@ -960,12 +960,12 @@ public Object valueForDisplay(Object value) { } @Override - public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) { + public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup searchLookup, String format) { if (format != null) { throw new IllegalArgumentException("Field [" + name() + "] of type [" + typeName() + "] doesn't support formats."); } - return new SourceValueFetcher(name(), mapperService, nullValue) { + return new SourceValueFetcher(name(), context, nullValue) { @Override protected Object parseSourceValue(Object value) { if (value.equals("")) { diff --git a/server/src/main/java/org/elasticsearch/index/mapper/RangeFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/RangeFieldMapper.java index 2da4da9d5bea3..dc685d9573778 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/RangeFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/RangeFieldMapper.java @@ -189,13 +189,13 @@ public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName, S } @Override - public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) { + public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup searchLookup, String format) { DateFormatter defaultFormatter = dateTimeFormatter(); DateFormatter formatter = format != null ? DateFormatter.forPattern(format).withLocale(defaultFormatter.locale()) : defaultFormatter; - return new SourceValueFetcher(name(), mapperService) { + return new SourceValueFetcher(name(), context) { @Override @SuppressWarnings("unchecked") diff --git a/server/src/main/java/org/elasticsearch/index/mapper/RoutingFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/RoutingFieldMapper.java index 874eb8ac84a1d..cbf894a438df4 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/RoutingFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/RoutingFieldMapper.java @@ -23,6 +23,7 @@ import org.apache.lucene.document.FieldType; import org.apache.lucene.index.IndexOptions; import org.elasticsearch.common.lucene.Lucene; +import org.elasticsearch.index.query.QueryShardContext; import org.elasticsearch.search.lookup.SearchLookup; import java.util.Collections; @@ -95,7 +96,7 @@ public String typeName() { } @Override - public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup lookup, String format) { + public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup lookup, String format) { throw new UnsupportedOperationException("Cannot fetch values for internal field [" + name() + "]."); } } diff --git a/server/src/main/java/org/elasticsearch/index/mapper/SeqNoFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/SeqNoFieldMapper.java index 3dd29e48c73f8..d0f9eb735f618 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/SeqNoFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/SeqNoFieldMapper.java @@ -122,7 +122,7 @@ private long parse(Object value) { } @Override - public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup lookup, String format) { + public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup lookup, String format) { throw new UnsupportedOperationException("Cannot fetch values for internal field [" + name() + "]."); } diff --git a/server/src/main/java/org/elasticsearch/index/mapper/SourceFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/SourceFieldMapper.java index 8609aec8c4857..e4147a4d8addd 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/SourceFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/SourceFieldMapper.java @@ -112,7 +112,7 @@ public String typeName() { } @Override - public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup lookup, String format) { + public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup lookup, String format) { throw new UnsupportedOperationException("Cannot fetch values for internal field [" + name() + "]."); } diff --git a/server/src/main/java/org/elasticsearch/index/mapper/SourceValueFetcher.java b/server/src/main/java/org/elasticsearch/index/mapper/SourceValueFetcher.java index be27abf479d76..62bffa51083d1 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/SourceValueFetcher.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/SourceValueFetcher.java @@ -20,6 +20,7 @@ package org.elasticsearch.index.mapper; import org.elasticsearch.common.Nullable; +import org.elasticsearch.index.query.QueryShardContext; import org.elasticsearch.search.lookup.SourceLookup; import java.util.ArrayDeque; @@ -39,17 +40,17 @@ public abstract class SourceValueFetcher implements ValueFetcher { private final Set sourcePaths; private final @Nullable Object nullValue; - public SourceValueFetcher(String fieldName, MapperService mapperService) { - this(fieldName, mapperService, null); + public SourceValueFetcher(String fieldName, QueryShardContext context) { + this(fieldName, context, null); } /** * @param fieldName The name of the field. - * @param mapperService A mapper service. + * @param context The query shard context * @param nullValue A optional substitute value if the _source value is 'null'. */ - public SourceValueFetcher(String fieldName, MapperService mapperService, Object nullValue) { - this.sourcePaths = mapperService.sourcePath(fieldName); + public SourceValueFetcher(String fieldName, QueryShardContext context, Object nullValue) { + this.sourcePaths = context.sourcePath(fieldName); this.nullValue = nullValue; } @@ -91,11 +92,11 @@ public List fetchValues(SourceLookup lookup) { /** * Creates a {@link SourceValueFetcher} that passes through source values unmodified. */ - public static SourceValueFetcher identity(String fieldName, MapperService mapperService, String format) { + public static SourceValueFetcher identity(String fieldName, QueryShardContext context, String format) { if (format != null) { throw new IllegalArgumentException("Field [" + fieldName + "] doesn't support formats."); } - return new SourceValueFetcher(fieldName, mapperService) { + return new SourceValueFetcher(fieldName, context) { @Override protected Object parseSourceValue(Object value) { return value; @@ -106,11 +107,11 @@ protected Object parseSourceValue(Object value) { /** * Creates a {@link SourceValueFetcher} that converts source values to strings. */ - public static SourceValueFetcher toString(String fieldName, MapperService mapperService, String format) { + public static SourceValueFetcher toString(String fieldName, QueryShardContext context, String format) { if (format != null) { throw new IllegalArgumentException("Field [" + fieldName + "] doesn't support formats."); } - return new SourceValueFetcher(fieldName, mapperService) { + return new SourceValueFetcher(fieldName, context) { @Override protected Object parseSourceValue(Object value) { return value.toString(); diff --git a/server/src/main/java/org/elasticsearch/index/mapper/TextFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/TextFieldMapper.java index 95ba93088c66c..07fb1341d28e9 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/TextFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/TextFieldMapper.java @@ -465,10 +465,10 @@ public String typeName() { } @Override - public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) { + public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup searchLookup, String format) { // Because this internal field is modelled as a multi-field, SourceValueFetcher will look up its // parent field in _source. So we don't need to use the parent field name here. - return SourceValueFetcher.toString(name(), mapperService, format); + return SourceValueFetcher.toString(name(), context, format); } @Override @@ -495,10 +495,10 @@ static final class PrefixFieldType extends StringFieldType { } @Override - public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) { + public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup searchLookup, String format) { // Because this internal field is modelled as a multi-field, SourceValueFetcher will look up its // parent field in _source. So we don't need to use the parent field name here. - return SourceValueFetcher.toString(name(), mapperService, format); + return SourceValueFetcher.toString(name(), context, format); } void setAnalyzer(NamedAnalyzer delegate) { @@ -693,8 +693,8 @@ public String typeName() { } @Override - public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) { - return SourceValueFetcher.toString(name(), mapperService, format); + public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup searchLookup, String format) { + return SourceValueFetcher.toString(name(), context, format); } @Override diff --git a/server/src/main/java/org/elasticsearch/index/mapper/TypeFieldType.java b/server/src/main/java/org/elasticsearch/index/mapper/TypeFieldType.java index 1c50ed7b41d1e..add469d174efe 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/TypeFieldType.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/TypeFieldType.java @@ -76,7 +76,7 @@ public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName, S } @Override - public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) { + public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup searchLookup, String format) { throw new UnsupportedOperationException("Cannot fetch values for internal field [" + name() + "]."); } diff --git a/server/src/main/java/org/elasticsearch/index/mapper/VersionFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/VersionFieldMapper.java index 1c31f71fc1ebd..55273d1ae37b4 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/VersionFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/VersionFieldMapper.java @@ -56,7 +56,7 @@ public Query termQuery(Object value, QueryShardContext context) { } @Override - public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup lookup, String format) { + public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup lookup, String format) { throw new UnsupportedOperationException("Cannot fetch values for internal field [" + name() + "]."); } } diff --git a/server/src/main/java/org/elasticsearch/index/query/QueryShardContext.java b/server/src/main/java/org/elasticsearch/index/query/QueryShardContext.java index 368daac1729b0..4a8c5c262d053 100644 --- a/server/src/main/java/org/elasticsearch/index/query/QueryShardContext.java +++ b/server/src/main/java/org/elasticsearch/index/query/QueryShardContext.java @@ -270,6 +270,14 @@ public ObjectMapper getObjectMapper(String name) { return mapperService.getObjectMapper(name); } + public boolean isMetadataField(String field) { + return mapperService.isMetadataField(field); + } + + public Set sourcePath(String fullName) { + return mapperService.sourcePath(fullName); + } + /** * Given a type (eg. long, string, ...), returns an anonymous field type that can be used for search operations. * Generally used to handle unmapped fields in the context of sorting. diff --git a/server/src/main/java/org/elasticsearch/search/fetch/FetchContext.java b/server/src/main/java/org/elasticsearch/search/fetch/FetchContext.java index 19b0989e1dc35..1071b5fcf00e7 100644 --- a/server/src/main/java/org/elasticsearch/search/fetch/FetchContext.java +++ b/server/src/main/java/org/elasticsearch/search/fetch/FetchContext.java @@ -23,6 +23,7 @@ import org.elasticsearch.index.IndexSettings; import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.query.ParsedQuery; +import org.elasticsearch.index.query.QueryShardContext; import org.elasticsearch.search.SearchExtBuilder; import org.elasticsearch.search.fetch.subphase.FetchDocValuesContext; import org.elasticsearch.search.fetch.subphase.FetchFieldsContext; @@ -207,4 +208,8 @@ public ScriptFieldsContext scriptFields() { public SearchExtBuilder getSearchExt(String name) { return searchContext.getSearchExt(name); } + + public QueryShardContext getQueryShardContext() { + return searchContext.getQueryShardContext(); + } } diff --git a/server/src/main/java/org/elasticsearch/search/fetch/subphase/FetchFieldsPhase.java b/server/src/main/java/org/elasticsearch/search/fetch/subphase/FetchFieldsPhase.java index efcffbea02db5..58e73cbca82a6 100644 --- a/server/src/main/java/org/elasticsearch/search/fetch/subphase/FetchFieldsPhase.java +++ b/server/src/main/java/org/elasticsearch/search/fetch/subphase/FetchFieldsPhase.java @@ -22,7 +22,6 @@ import org.apache.lucene.index.LeafReaderContext; import org.elasticsearch.common.document.DocumentField; import org.elasticsearch.index.mapper.IgnoredFieldMapper; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.search.SearchHit; import org.elasticsearch.search.fetch.FetchContext; import org.elasticsearch.search.fetch.FetchSubPhase; @@ -48,14 +47,13 @@ public FetchSubPhaseProcessor getProcessor(FetchContext fetchContext) { return null; } - MapperService mapperService = fetchContext.mapperService(); SearchLookup searchLookup = fetchContext.searchLookup(); if (fetchContext.mapperService().documentMapper().sourceMapper().enabled() == false) { throw new IllegalArgumentException("Unable to retrieve the requested [fields] since _source is disabled " + "in the mappings for index [" + fetchContext.getIndexName() + "]"); } - FieldFetcher fieldFetcher = FieldFetcher.create(mapperService, searchLookup, fetchFieldsContext.fields()); + FieldFetcher fieldFetcher = FieldFetcher.create(fetchContext.getQueryShardContext(), searchLookup, fetchFieldsContext.fields()); return new FetchSubPhaseProcessor() { @Override public void setNextReader(LeafReaderContext readerContext) { diff --git a/server/src/main/java/org/elasticsearch/search/fetch/subphase/FieldFetcher.java b/server/src/main/java/org/elasticsearch/search/fetch/subphase/FieldFetcher.java index 4e3a0dbebcd19..dce613955ca72 100644 --- a/server/src/main/java/org/elasticsearch/search/fetch/subphase/FieldFetcher.java +++ b/server/src/main/java/org/elasticsearch/search/fetch/subphase/FieldFetcher.java @@ -22,8 +22,8 @@ import org.apache.lucene.index.LeafReaderContext; import org.elasticsearch.common.document.DocumentField; import org.elasticsearch.index.mapper.MappedFieldType; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.ValueFetcher; +import org.elasticsearch.index.query.QueryShardContext; import org.elasticsearch.search.lookup.SearchLookup; import org.elasticsearch.search.lookup.SourceLookup; @@ -40,7 +40,7 @@ * Then given a specific document, it can retrieve the corresponding fields from the document's source. */ public class FieldFetcher { - public static FieldFetcher create(MapperService mapperService, + public static FieldFetcher create(QueryShardContext context, SearchLookup searchLookup, Collection fieldAndFormats) { @@ -50,13 +50,13 @@ public static FieldFetcher create(MapperService mapperService, String fieldPattern = fieldAndFormat.field; String format = fieldAndFormat.format; - Collection concreteFields = mapperService.simpleMatchToFullName(fieldPattern); + Collection concreteFields = context.simpleMatchToIndexNames(fieldPattern); for (String field : concreteFields) { - MappedFieldType ft = mapperService.fieldType(field); - if (ft == null || mapperService.isMetadataField(field)) { + MappedFieldType ft = context.getFieldType(field); + if (ft == null || context.isMetadataField(field)) { continue; } - ValueFetcher valueFetcher = ft.valueFetcher(mapperService, searchLookup, format); + ValueFetcher valueFetcher = ft.valueFetcher(context, searchLookup, format); fieldContexts.add(new FieldContext(field, valueFetcher)); } } diff --git a/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataIndexTemplateServiceTests.java b/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataIndexTemplateServiceTests.java index bfec74ba87c15..2ecede4bc32f3 100644 --- a/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataIndexTemplateServiceTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataIndexTemplateServiceTests.java @@ -1586,7 +1586,7 @@ public static class MetadataTimestampFieldMapper extends MetadataFieldMapper { public MetadataTimestampFieldMapper(boolean enabled) { super(new MappedFieldType("_data_stream_timestamp", false, false, false, TextSearchInfo.NONE, Map.of()) { @Override - public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) { + public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup searchLookup, String format) { throw new UnsupportedOperationException(); } diff --git a/server/src/test/java/org/elasticsearch/index/mapper/DocumentFieldMapperTests.java b/server/src/test/java/org/elasticsearch/index/mapper/DocumentFieldMapperTests.java index 3ab58de67ed6d..66766039e7c61 100644 --- a/server/src/test/java/org/elasticsearch/index/mapper/DocumentFieldMapperTests.java +++ b/server/src/test/java/org/elasticsearch/index/mapper/DocumentFieldMapperTests.java @@ -26,6 +26,7 @@ import org.apache.lucene.util.LuceneTestCase; import org.elasticsearch.index.analysis.AnalyzerScope; import org.elasticsearch.index.analysis.NamedAnalyzer; +import org.elasticsearch.index.query.QueryShardContext; import org.elasticsearch.search.lookup.SearchLookup; import java.io.IOException; @@ -71,7 +72,7 @@ private FakeFieldType(String name) { } @Override - public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) { + public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup searchLookup, String format) { throw new UnsupportedOperationException(); } diff --git a/server/src/test/java/org/elasticsearch/index/mapper/ExternalMapper.java b/server/src/test/java/org/elasticsearch/index/mapper/ExternalMapper.java index 393eea9696339..969eefee53b8a 100644 --- a/server/src/test/java/org/elasticsearch/index/mapper/ExternalMapper.java +++ b/server/src/test/java/org/elasticsearch/index/mapper/ExternalMapper.java @@ -24,6 +24,7 @@ import org.elasticsearch.common.geo.builders.PointBuilder; import org.elasticsearch.common.lucene.Lucene; import org.elasticsearch.geometry.Point; +import org.elasticsearch.index.query.QueryShardContext; import org.elasticsearch.search.lookup.SearchLookup; import java.io.IOException; @@ -103,8 +104,8 @@ public String typeName() { } @Override - public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) { - return SourceValueFetcher.identity(name(), mapperService, format); + public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup searchLookup, String format) { + return SourceValueFetcher.identity(name(), context, format); } } diff --git a/server/src/test/java/org/elasticsearch/index/mapper/FakeStringFieldMapper.java b/server/src/test/java/org/elasticsearch/index/mapper/FakeStringFieldMapper.java index 307026e3c2434..1d8f88d9aa03f 100644 --- a/server/src/test/java/org/elasticsearch/index/mapper/FakeStringFieldMapper.java +++ b/server/src/test/java/org/elasticsearch/index/mapper/FakeStringFieldMapper.java @@ -23,6 +23,7 @@ import org.apache.lucene.document.FieldType; import org.apache.lucene.index.IndexOptions; import org.elasticsearch.common.lucene.Lucene; +import org.elasticsearch.index.query.QueryShardContext; import org.elasticsearch.search.lookup.SearchLookup; import java.io.IOException; @@ -76,8 +77,8 @@ public String typeName() { } @Override - public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) { - return SourceValueFetcher.toString(name(), mapperService, format); + public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup searchLookup, String format) { + return SourceValueFetcher.toString(name(), context, format); } } diff --git a/server/src/test/java/org/elasticsearch/search/collapse/CollapseBuilderTests.java b/server/src/test/java/org/elasticsearch/search/collapse/CollapseBuilderTests.java index be8d53ce1f11b..a6f4d9f912832 100644 --- a/server/src/test/java/org/elasticsearch/search/collapse/CollapseBuilderTests.java +++ b/server/src/test/java/org/elasticsearch/search/collapse/CollapseBuilderTests.java @@ -32,7 +32,6 @@ import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.mapper.KeywordFieldMapper; import org.elasticsearch.index.mapper.MappedFieldType; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.NumberFieldMapper; import org.elasticsearch.index.mapper.TextSearchInfo; import org.elasticsearch.index.mapper.ValueFetcher; @@ -209,7 +208,7 @@ public String typeName() { } @Override - public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) { + public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup searchLookup, String format) { throw new UnsupportedOperationException(); } diff --git a/server/src/test/java/org/elasticsearch/search/fetch/subphase/FieldFetcherTests.java b/server/src/test/java/org/elasticsearch/search/fetch/subphase/FieldFetcherTests.java index 270729167ddcf..181f99b982cbf 100644 --- a/server/src/test/java/org/elasticsearch/search/fetch/subphase/FieldFetcherTests.java +++ b/server/src/test/java/org/elasticsearch/search/fetch/subphase/FieldFetcherTests.java @@ -19,13 +19,17 @@ package org.elasticsearch.search.fetch.subphase; +import org.elasticsearch.Version; +import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.document.DocumentField; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.IndexService; +import org.elasticsearch.index.IndexSettings; import org.elasticsearch.index.mapper.MapperService; +import org.elasticsearch.index.query.QueryShardContext; import org.elasticsearch.search.lookup.SourceLookup; import org.elasticsearch.test.ESSingleNodeTestCase; @@ -389,20 +393,20 @@ public void testTextSubFields() throws IOException { } } - private Map fetchFields(MapperService mapperService, XContentBuilder source, String fieldPattern) + private static Map fetchFields(MapperService mapperService, XContentBuilder source, String fieldPattern) throws IOException { List fields = List.of(new FieldAndFormat(fieldPattern, null)); return fetchFields(mapperService, source, fields); } - private Map fetchFields(MapperService mapperService, XContentBuilder source, List fields) + private static Map fetchFields(MapperService mapperService, XContentBuilder source, List fields) throws IOException { SourceLookup sourceLookup = new SourceLookup(); sourceLookup.setSource(BytesReference.bytes(source)); - FieldFetcher fieldFetcher = FieldFetcher.create(mapperService, null, fields); + FieldFetcher fieldFetcher = FieldFetcher.create(createQueryShardContext(mapperService), null, fields); return fieldFetcher.fetch(sourceLookup, Set.of()); } @@ -426,4 +430,15 @@ public MapperService createMapperService() throws IOException { IndexService indexService = createIndex("index", Settings.EMPTY, mapping); return indexService.mapperService(); } + + private static QueryShardContext createQueryShardContext(MapperService mapperService) { + Settings settings = Settings.builder().put("index.version.created", Version.CURRENT) + .put("index.number_of_shards", 1) + .put("index.number_of_replicas", 0) + .put(IndexMetadata.SETTING_INDEX_UUID, "uuid").build(); + IndexMetadata indexMetadata = new IndexMetadata.Builder("index").settings(settings).build(); + IndexSettings indexSettings = new IndexSettings(indexMetadata, settings); + return new QueryShardContext(0, indexSettings, null, null, null, mapperService, null, null, null, null, null, null, null, null, + null, null, null); + } } diff --git a/server/src/test/java/org/elasticsearch/search/slice/SliceBuilderTests.java b/server/src/test/java/org/elasticsearch/search/slice/SliceBuilderTests.java index f015c40a580df..c7ebaa5d52de2 100644 --- a/server/src/test/java/org/elasticsearch/search/slice/SliceBuilderTests.java +++ b/server/src/test/java/org/elasticsearch/search/slice/SliceBuilderTests.java @@ -51,7 +51,6 @@ import org.elasticsearch.index.IndexSettings; import org.elasticsearch.index.fielddata.IndexNumericFieldData; import org.elasticsearch.index.mapper.MappedFieldType; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.TextSearchInfo; import org.elasticsearch.index.mapper.ValueFetcher; import org.elasticsearch.index.query.QueryShardContext; @@ -126,7 +125,7 @@ private QueryShardContext createShardContext(Version indexVersionCreated, IndexR TextSearchInfo.NONE, Collections.emptyMap()) { @Override - public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) { + public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup searchLookup, String format) { throw new UnsupportedOperationException(); } diff --git a/test/framework/src/main/java/org/elasticsearch/index/mapper/FieldTypeTestCase.java b/test/framework/src/main/java/org/elasticsearch/index/mapper/FieldTypeTestCase.java index 3e539633ae355..cd4a8779ea1d4 100644 --- a/test/framework/src/main/java/org/elasticsearch/index/mapper/FieldTypeTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/index/mapper/FieldTypeTestCase.java @@ -52,10 +52,10 @@ public static List fetchSourceValue(MappedFieldType fieldType, Object sourceV public static List fetchSourceValue(MappedFieldType fieldType, Object sourceValue, String format) throws IOException { String field = fieldType.name(); - MapperService mapperService = mock(MapperService.class); - when(mapperService.sourcePath(field)).thenReturn(Set.of(field)); + QueryShardContext queryShardContext = mock(QueryShardContext.class); + when(queryShardContext.sourcePath(field)).thenReturn(Set.of(field)); - ValueFetcher fetcher = fieldType.valueFetcher(mapperService, null, format); + ValueFetcher fetcher = fieldType.valueFetcher(queryShardContext, null, format); SourceLookup lookup = new SourceLookup(); lookup.setSource(Collections.singletonMap(field, sourceValue)); return fetcher.fetchValues(lookup); diff --git a/test/framework/src/main/java/org/elasticsearch/index/mapper/MockFieldMapper.java b/test/framework/src/main/java/org/elasticsearch/index/mapper/MockFieldMapper.java index 886c22bbee22b..d3968a43b127c 100644 --- a/test/framework/src/main/java/org/elasticsearch/index/mapper/MockFieldMapper.java +++ b/test/framework/src/main/java/org/elasticsearch/index/mapper/MockFieldMapper.java @@ -22,6 +22,7 @@ import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.index.query.QueryShardContext; import org.elasticsearch.search.lookup.SearchLookup; import java.util.Collections; @@ -70,7 +71,7 @@ public String typeName() { } @Override - public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) { + public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup searchLookup, String format) { throw new UnsupportedOperationException(); } } diff --git a/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/mapper/HistogramFieldMapper.java b/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/mapper/HistogramFieldMapper.java index 12842bcbc2624..3eebed3348ef3 100644 --- a/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/mapper/HistogramFieldMapper.java +++ b/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/mapper/HistogramFieldMapper.java @@ -34,7 +34,6 @@ import org.elasticsearch.index.mapper.FieldMapper; import org.elasticsearch.index.mapper.MappedFieldType; import org.elasticsearch.index.mapper.MapperParsingException; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.ParseContext; import org.elasticsearch.index.mapper.SourceValueFetcher; import org.elasticsearch.index.mapper.TextSearchInfo; @@ -134,8 +133,8 @@ public String typeName() { } @Override - public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) { - return SourceValueFetcher.identity(name(), mapperService, format); + public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup searchLookup, String format) { + return SourceValueFetcher.identity(name(), context, format); } @Override diff --git a/x-pack/plugin/data-streams/src/main/java/org/elasticsearch/xpack/datastreams/mapper/DataStreamTimestampFieldMapper.java b/x-pack/plugin/data-streams/src/main/java/org/elasticsearch/xpack/datastreams/mapper/DataStreamTimestampFieldMapper.java index 8cfb89c68e658..441bfadbc424d 100644 --- a/x-pack/plugin/data-streams/src/main/java/org/elasticsearch/xpack/datastreams/mapper/DataStreamTimestampFieldMapper.java +++ b/x-pack/plugin/data-streams/src/main/java/org/elasticsearch/xpack/datastreams/mapper/DataStreamTimestampFieldMapper.java @@ -17,7 +17,6 @@ import org.elasticsearch.index.mapper.FieldMapper; import org.elasticsearch.index.mapper.MappedFieldType; import org.elasticsearch.index.mapper.Mapper; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.MappingLookup; import org.elasticsearch.index.mapper.MetadataFieldMapper; import org.elasticsearch.index.mapper.ParseContext; @@ -63,7 +62,7 @@ public Query existsQuery(QueryShardContext context) { } @Override - public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) { + public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup searchLookup, String format) { throw new UnsupportedOperationException(); } } diff --git a/x-pack/plugin/mapper-constant-keyword/src/main/java/org/elasticsearch/xpack/constantkeyword/mapper/ConstantKeywordFieldMapper.java b/x-pack/plugin/mapper-constant-keyword/src/main/java/org/elasticsearch/xpack/constantkeyword/mapper/ConstantKeywordFieldMapper.java index 54246b692c968..7e506de9ab8fb 100644 --- a/x-pack/plugin/mapper-constant-keyword/src/main/java/org/elasticsearch/xpack/constantkeyword/mapper/ConstantKeywordFieldMapper.java +++ b/x-pack/plugin/mapper-constant-keyword/src/main/java/org/elasticsearch/xpack/constantkeyword/mapper/ConstantKeywordFieldMapper.java @@ -31,7 +31,6 @@ import org.elasticsearch.index.mapper.MappedFieldType; import org.elasticsearch.index.mapper.Mapper; import org.elasticsearch.index.mapper.MapperParsingException; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.ParseContext; import org.elasticsearch.index.mapper.ValueFetcher; import org.elasticsearch.index.query.QueryShardContext; @@ -130,7 +129,7 @@ public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName, S } @Override - public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) { + public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup searchLookup, String format) { if (format != null) { throw new IllegalArgumentException("Field [" + name() + "] of type [" + typeName() + "] doesn't support formats."); } diff --git a/x-pack/plugin/mapper-flattened/src/main/java/org/elasticsearch/xpack/flattened/mapper/FlattenedFieldMapper.java b/x-pack/plugin/mapper-flattened/src/main/java/org/elasticsearch/xpack/flattened/mapper/FlattenedFieldMapper.java index 0fef5c266ecdc..0d8d4d5bd93d3 100644 --- a/x-pack/plugin/mapper-flattened/src/main/java/org/elasticsearch/xpack/flattened/mapper/FlattenedFieldMapper.java +++ b/x-pack/plugin/mapper-flattened/src/main/java/org/elasticsearch/xpack/flattened/mapper/FlattenedFieldMapper.java @@ -32,7 +32,6 @@ import org.elasticsearch.index.mapper.FieldMapper; import org.elasticsearch.index.mapper.MappedFieldType; import org.elasticsearch.index.mapper.Mapper; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.ParseContext; import org.elasticsearch.index.mapper.SourceValueFetcher; import org.elasticsearch.index.mapper.StringFieldType; @@ -257,7 +256,7 @@ public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName, S } @Override - public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) { + public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup searchLookup, String format) { // This is an internal field but it can match a field pattern so we return an empty list. return lookup -> List.of(); } @@ -404,8 +403,8 @@ public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName, S } @Override - public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) { - return SourceValueFetcher.identity(name(), mapperService, format); + public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup searchLookup, String format) { + return SourceValueFetcher.identity(name(), context, format); } } diff --git a/x-pack/plugin/mapper-unsigned-long/src/main/java/org/elasticsearch/xpack/unsignedlong/UnsignedLongFieldMapper.java b/x-pack/plugin/mapper-unsigned-long/src/main/java/org/elasticsearch/xpack/unsignedlong/UnsignedLongFieldMapper.java index 50a19669f42f5..107bad4dc2ba6 100644 --- a/x-pack/plugin/mapper-unsigned-long/src/main/java/org/elasticsearch/xpack/unsignedlong/UnsignedLongFieldMapper.java +++ b/x-pack/plugin/mapper-unsigned-long/src/main/java/org/elasticsearch/xpack/unsignedlong/UnsignedLongFieldMapper.java @@ -26,7 +26,6 @@ import org.elasticsearch.index.mapper.FieldMapper; import org.elasticsearch.index.mapper.MappedFieldType; import org.elasticsearch.index.mapper.MapperParsingException; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.ParseContext; import org.elasticsearch.index.mapper.SimpleMappedFieldType; import org.elasticsearch.index.mapper.SourceValueFetcher; @@ -231,12 +230,12 @@ public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName, S } @Override - public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) { + public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup searchLookup, String format) { if (format != null) { throw new IllegalArgumentException("Field [" + name() + "] of type [" + typeName() + "] doesn't support formats."); } - return new SourceValueFetcher(name(), mapperService, nullValueFormatted) { + return new SourceValueFetcher(name(), context, nullValueFormatted) { @Override protected Object parseSourceValue(Object value) { if (value.equals("")) { diff --git a/x-pack/plugin/mapper-version/src/main/java/org/elasticsearch/xpack/versionfield/VersionStringFieldMapper.java b/x-pack/plugin/mapper-version/src/main/java/org/elasticsearch/xpack/versionfield/VersionStringFieldMapper.java index 4dcf2de16ce11..afa53e4f493b7 100644 --- a/x-pack/plugin/mapper-version/src/main/java/org/elasticsearch/xpack/versionfield/VersionStringFieldMapper.java +++ b/x-pack/plugin/mapper-version/src/main/java/org/elasticsearch/xpack/versionfield/VersionStringFieldMapper.java @@ -36,7 +36,6 @@ import org.elasticsearch.index.mapper.FieldMapper; import org.elasticsearch.index.mapper.MappedFieldType; import org.elasticsearch.index.mapper.Mapper; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.ParseContext; import org.elasticsearch.index.mapper.SourceValueFetcher; import org.elasticsearch.index.mapper.TermBasedFieldType; @@ -132,8 +131,8 @@ public String typeName() { } @Override - public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) { - return SourceValueFetcher.toString(name(), mapperService, format); + public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup searchLookup, String format) { + return SourceValueFetcher.toString(name(), context, format); } @Override diff --git a/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/mapper/AbstractScriptFieldType.java b/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/mapper/AbstractScriptFieldType.java index 42958b9599e21..0feb612f82018 100644 --- a/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/mapper/AbstractScriptFieldType.java +++ b/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/mapper/AbstractScriptFieldType.java @@ -18,7 +18,6 @@ import org.elasticsearch.common.unit.Fuzziness; import org.elasticsearch.index.mapper.DocValueFetcher; import org.elasticsearch.index.mapper.MappedFieldType; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.TextSearchInfo; import org.elasticsearch.index.mapper.ValueFetcher; import org.elasticsearch.index.query.QueryShardContext; @@ -214,7 +213,7 @@ protected Locale formatLocale() { } @Override - public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup lookup, String format) { + public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup lookup, String format) { return new DocValueFetcher(docValueFormat(format, null), lookup.doc().getForField(this)); } } diff --git a/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/mapper/DenseVectorFieldMapper.java b/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/mapper/DenseVectorFieldMapper.java index fedc2ed8051bd..156aca84b9cd7 100644 --- a/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/mapper/DenseVectorFieldMapper.java +++ b/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/mapper/DenseVectorFieldMapper.java @@ -18,7 +18,6 @@ import org.elasticsearch.index.mapper.FieldMapper; import org.elasticsearch.index.mapper.MappedFieldType; import org.elasticsearch.index.mapper.MapperParsingException; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.ParseContext; import org.elasticsearch.index.mapper.TextSearchInfo; import org.elasticsearch.index.mapper.ValueFetcher; @@ -109,11 +108,11 @@ public String typeName() { } @Override - public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) { + public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup searchLookup, String format) { if (format != null) { throw new IllegalArgumentException("Field [" + name() + "] of type [" + typeName() + "] doesn't support formats."); } - return new ArraySourceValueFetcher(name(), mapperService) { + return new ArraySourceValueFetcher(name(), context) { @Override protected Object parseSourceValue(Object value) { return value; diff --git a/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/mapper/SparseVectorFieldMapper.java b/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/mapper/SparseVectorFieldMapper.java index 65813d84d8aa9..7ce2fee08f1d2 100644 --- a/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/mapper/SparseVectorFieldMapper.java +++ b/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/mapper/SparseVectorFieldMapper.java @@ -12,7 +12,6 @@ import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.index.mapper.FieldMapper; import org.elasticsearch.index.mapper.MappedFieldType; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.ParseContext; import org.elasticsearch.index.mapper.TextSearchInfo; import org.elasticsearch.index.mapper.ValueFetcher; @@ -87,7 +86,7 @@ public DocValueFormat docValueFormat(String format, ZoneId timeZone) { } @Override - public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) { + public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup searchLookup, String format) { throw new UnsupportedOperationException(ERROR_MESSAGE_7X); } diff --git a/x-pack/plugin/wildcard/src/main/java/org/elasticsearch/xpack/wildcard/mapper/WildcardFieldMapper.java b/x-pack/plugin/wildcard/src/main/java/org/elasticsearch/xpack/wildcard/mapper/WildcardFieldMapper.java index 55ecf1fdd59d1..c56ebfb41a871 100644 --- a/x-pack/plugin/wildcard/src/main/java/org/elasticsearch/xpack/wildcard/mapper/WildcardFieldMapper.java +++ b/x-pack/plugin/wildcard/src/main/java/org/elasticsearch/xpack/wildcard/mapper/WildcardFieldMapper.java @@ -56,7 +56,6 @@ import org.elasticsearch.index.mapper.FieldMapper; import org.elasticsearch.index.mapper.KeywordFieldMapper; import org.elasticsearch.index.mapper.MappedFieldType; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.ParseContext; import org.elasticsearch.index.mapper.ParseContext.Document; import org.elasticsearch.index.mapper.SourceValueFetcher; @@ -905,12 +904,12 @@ public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName, S } @Override - public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) { + public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup searchLookup, String format) { if (format != null) { throw new IllegalArgumentException("Field [" + name() + "] of type [" + typeName() + "] doesn't support formats."); } - return new SourceValueFetcher(name(), mapperService, nullValue) { + return new SourceValueFetcher(name(), context, nullValue) { @Override protected String parseSourceValue(Object value) { String keywordValue = value.toString();