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 5080e5241ddf3..dab4d1ef3621b 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 @@ -197,11 +197,11 @@ public Query rangeQuery(Object lowerTerm, Object upperTerm, boolean includeLower @Override public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName, Supplier searchLookup) { failIfNoDocValues(); - return (cache, breakerService, mapperService) -> { + return (cache, breakerService) -> { final IndexNumericFieldData scaledValues = new SortedNumericIndexFieldData.Builder( name(), IndexNumericFieldData.NumericType.LONG - ).build(cache, breakerService, mapperService); + ).build(cache, breakerService); return new ScaledFloatIndexFieldData(scaledValues, scalingFactor); }; } diff --git a/modules/mapper-extras/src/test/java/org/elasticsearch/index/mapper/ScaledFloatFieldTypeTests.java b/modules/mapper-extras/src/test/java/org/elasticsearch/index/mapper/ScaledFloatFieldTypeTests.java index 976c0582c9c7f..19ff1edeaa2a2 100644 --- a/modules/mapper-extras/src/test/java/org/elasticsearch/index/mapper/ScaledFloatFieldTypeTests.java +++ b/modules/mapper-extras/src/test/java/org/elasticsearch/index/mapper/ScaledFloatFieldTypeTests.java @@ -156,7 +156,7 @@ public void testFieldData() throws IOException { = new ScaledFloatFieldMapper.ScaledFloatFieldType("scaled_float1", scalingFactor); IndexNumericFieldData fielddata = (IndexNumericFieldData) f1.fielddataBuilder("index", () -> { throw new UnsupportedOperationException(); - }).build(null, null, null); + }).build(null, null); assertEquals(fielddata.getNumericType(), IndexNumericFieldData.NumericType.DOUBLE); LeafNumericFieldData leafFieldData = fielddata.load(reader.leaves().get(0)); SortedNumericDoubleValues values = leafFieldData.getDoubleValues(); @@ -169,7 +169,7 @@ public void testFieldData() throws IOException { = new ScaledFloatFieldMapper.ScaledFloatFieldType("scaled_float2", scalingFactor); fielddata = (IndexNumericFieldData) f2.fielddataBuilder("index", () -> { throw new UnsupportedOperationException(); - }).build(null, null, null); + }).build(null, null); leafFieldData = fielddata.load(reader.leaves().get(0)); values = leafFieldData.getDoubleValues(); assertTrue(values.advanceExact(0)); diff --git a/modules/percolator/src/main/java/org/elasticsearch/percolator/PercolateQueryBuilder.java b/modules/percolator/src/main/java/org/elasticsearch/percolator/PercolateQueryBuilder.java index b7959f3b5d8a6..734b5e72da5a7 100644 --- a/modules/percolator/src/main/java/org/elasticsearch/percolator/PercolateQueryBuilder.java +++ b/modules/percolator/src/main/java/org/elasticsearch/percolator/PercolateQueryBuilder.java @@ -621,7 +621,7 @@ public > IFD getForField(MappedFieldType fieldType shardContext::lookup); IndexFieldDataCache cache = new IndexFieldDataCache.None(); CircuitBreakerService circuitBreaker = new NoneCircuitBreakerService(); - return (IFD) builder.build(cache, circuitBreaker, shardContext.getMapperService()); + return (IFD) builder.build(cache, circuitBreaker); } }; } diff --git a/server/src/main/java/org/elasticsearch/index/fielddata/IndexFieldData.java b/server/src/main/java/org/elasticsearch/index/fielddata/IndexFieldData.java index d33c8a9067ced..ef0b03ae95866 100644 --- a/server/src/main/java/org/elasticsearch/index/fielddata/IndexFieldData.java +++ b/server/src/main/java/org/elasticsearch/index/fielddata/IndexFieldData.java @@ -37,7 +37,6 @@ import org.elasticsearch.common.Nullable; import org.elasticsearch.common.util.BigArrays; import org.elasticsearch.index.fielddata.IndexFieldData.XFieldComparatorSource.Nested; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.indices.breaker.CircuitBreakerService; import org.elasticsearch.search.DocValueFormat; import org.elasticsearch.search.MultiValueMode; @@ -246,7 +245,7 @@ public abstract BucketedSort newBucketedSort(BigArrays bigArrays, SortOrder sort interface Builder { - IndexFieldData build(IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService); + IndexFieldData build(IndexFieldDataCache cache, CircuitBreakerService breakerService); } interface Global extends IndexFieldData { diff --git a/server/src/main/java/org/elasticsearch/index/fielddata/IndexFieldDataService.java b/server/src/main/java/org/elasticsearch/index/fielddata/IndexFieldDataService.java index a0bf9b2082c3f..aef27a1eb6090 100644 --- a/server/src/main/java/org/elasticsearch/index/fielddata/IndexFieldDataService.java +++ b/server/src/main/java/org/elasticsearch/index/fielddata/IndexFieldDataService.java @@ -135,7 +135,7 @@ public > IFD getForField(MappedFieldType fieldType } } - return (IFD) builder.build(cache, circuitBreakerService, mapperService); + return (IFD) builder.build(cache, circuitBreakerService); } /** diff --git a/server/src/main/java/org/elasticsearch/index/fielddata/plain/AbstractLatLonPointIndexFieldData.java b/server/src/main/java/org/elasticsearch/index/fielddata/plain/AbstractLatLonPointIndexFieldData.java index 81f75df206e9c..0df7ffb30a22c 100644 --- a/server/src/main/java/org/elasticsearch/index/fielddata/plain/AbstractLatLonPointIndexFieldData.java +++ b/server/src/main/java/org/elasticsearch/index/fielddata/plain/AbstractLatLonPointIndexFieldData.java @@ -31,7 +31,6 @@ import org.elasticsearch.index.fielddata.IndexFieldDataCache; import org.elasticsearch.index.fielddata.IndexGeoPointFieldData; import org.elasticsearch.index.fielddata.LeafGeoPointFieldData; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.indices.breaker.CircuitBreakerService; import org.elasticsearch.search.DocValueFormat; import org.elasticsearch.search.MultiValueMode; @@ -113,7 +112,7 @@ public Builder(String name, ValuesSourceType valuesSourceType) { } @Override - public IndexFieldData build(IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) { + public IndexFieldData build(IndexFieldDataCache cache, CircuitBreakerService breakerService) { // ignore breaker return new LatLonPointIndexFieldData(name, valuesSourceType); } diff --git a/server/src/main/java/org/elasticsearch/index/fielddata/plain/BinaryIndexFieldData.java b/server/src/main/java/org/elasticsearch/index/fielddata/plain/BinaryIndexFieldData.java index 8dd58316ffe97..1ddaf395becc5 100644 --- a/server/src/main/java/org/elasticsearch/index/fielddata/plain/BinaryIndexFieldData.java +++ b/server/src/main/java/org/elasticsearch/index/fielddata/plain/BinaryIndexFieldData.java @@ -27,7 +27,6 @@ import org.elasticsearch.index.fielddata.IndexFieldData.XFieldComparatorSource.Nested; import org.elasticsearch.index.fielddata.IndexFieldDataCache; import org.elasticsearch.index.fielddata.fieldcomparator.BytesRefFieldComparatorSource; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.indices.breaker.CircuitBreakerService; import org.elasticsearch.search.DocValueFormat; import org.elasticsearch.search.MultiValueMode; @@ -47,7 +46,7 @@ public Builder(String name, ValuesSourceType valuesSourceType) { } @Override - public BinaryIndexFieldData build(IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) { + public BinaryIndexFieldData build(IndexFieldDataCache cache, CircuitBreakerService breakerService) { return new BinaryIndexFieldData(name, valuesSourceType); } } diff --git a/server/src/main/java/org/elasticsearch/index/fielddata/plain/BytesBinaryIndexFieldData.java b/server/src/main/java/org/elasticsearch/index/fielddata/plain/BytesBinaryIndexFieldData.java index 093498b8bfd39..3ffd998a5635a 100644 --- a/server/src/main/java/org/elasticsearch/index/fielddata/plain/BytesBinaryIndexFieldData.java +++ b/server/src/main/java/org/elasticsearch/index/fielddata/plain/BytesBinaryIndexFieldData.java @@ -27,7 +27,6 @@ import org.elasticsearch.index.fielddata.IndexFieldData; import org.elasticsearch.index.fielddata.IndexFieldData.XFieldComparatorSource.Nested; import org.elasticsearch.index.fielddata.IndexFieldDataCache; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.indices.breaker.CircuitBreakerService; import org.elasticsearch.search.DocValueFormat; import org.elasticsearch.search.MultiValueMode; @@ -92,7 +91,7 @@ public Builder(String name, ValuesSourceType valuesSourceType) { } @Override - public IndexFieldData build(IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) { + public IndexFieldData build(IndexFieldDataCache cache, CircuitBreakerService breakerService) { // Ignore breaker return new BytesBinaryIndexFieldData(name, valuesSourceType); } diff --git a/server/src/main/java/org/elasticsearch/index/fielddata/plain/ConstantIndexFieldData.java b/server/src/main/java/org/elasticsearch/index/fielddata/plain/ConstantIndexFieldData.java index d3194240a0997..6d720f6191fe9 100644 --- a/server/src/main/java/org/elasticsearch/index/fielddata/plain/ConstantIndexFieldData.java +++ b/server/src/main/java/org/elasticsearch/index/fielddata/plain/ConstantIndexFieldData.java @@ -36,7 +36,6 @@ import org.elasticsearch.index.fielddata.IndexOrdinalsFieldData; import org.elasticsearch.index.fielddata.LeafOrdinalsFieldData; import org.elasticsearch.index.fielddata.fieldcomparator.BytesRefFieldComparatorSource; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.indices.breaker.CircuitBreakerService; import org.elasticsearch.search.DocValueFormat; import org.elasticsearch.search.MultiValueMode; @@ -44,30 +43,27 @@ import org.elasticsearch.search.sort.BucketedSort; import org.elasticsearch.search.sort.SortOrder; -import java.io.IOException; import java.util.Collection; import java.util.Collections; -import java.util.function.Function; public class ConstantIndexFieldData extends AbstractIndexOrdinalsFieldData { public static class Builder implements IndexFieldData.Builder { - private final Function valueFunction; + private final String constantValue; private final String name; private final ValuesSourceType valuesSourceType; - public Builder(Function valueFunction, String name, ValuesSourceType valuesSourceType) { - this.valueFunction = valueFunction; + public Builder(String constantValue, String name, ValuesSourceType valuesSourceType) { + this.constantValue = constantValue; this.name = name; this.valuesSourceType = valuesSourceType; } @Override - public IndexFieldData build(IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) { - return new ConstantIndexFieldData(name, valueFunction.apply(mapperService), valuesSourceType); + public IndexFieldData build(IndexFieldDataCache cache, CircuitBreakerService breakerService) { + return new ConstantIndexFieldData(name, constantValue, valuesSourceType); } - } private static class ConstantLeafFieldData extends AbstractLeafOrdinalsFieldData { @@ -116,7 +112,7 @@ public int ordValue() { } @Override - public boolean advanceExact(int target) throws IOException { + public boolean advanceExact(int target) { docID = target; return true; } @@ -126,7 +122,7 @@ public int docID() { return docID; } }; - return (SortedSetDocValues) DocValues.singleton(sortedValues); + return DocValues.singleton(sortedValues); } @Override @@ -148,8 +144,7 @@ public final LeafOrdinalsFieldData load(LeafReaderContext context) { } @Override - public LeafOrdinalsFieldData loadDirect(LeafReaderContext context) - throws Exception { + public LeafOrdinalsFieldData loadDirect(LeafReaderContext context) { return atomicFieldData; } @@ -172,7 +167,7 @@ public IndexOrdinalsFieldData loadGlobal(DirectoryReader indexReader) { } @Override - public IndexOrdinalsFieldData loadGlobalDirect(DirectoryReader indexReader) throws Exception { + public IndexOrdinalsFieldData loadGlobalDirect(DirectoryReader indexReader) { return loadGlobal(indexReader); } diff --git a/server/src/main/java/org/elasticsearch/index/fielddata/plain/PagedBytesIndexFieldData.java b/server/src/main/java/org/elasticsearch/index/fielddata/plain/PagedBytesIndexFieldData.java index 45afda314aae6..47e4142263dee 100644 --- a/server/src/main/java/org/elasticsearch/index/fielddata/plain/PagedBytesIndexFieldData.java +++ b/server/src/main/java/org/elasticsearch/index/fielddata/plain/PagedBytesIndexFieldData.java @@ -46,7 +46,6 @@ import org.elasticsearch.index.fielddata.fieldcomparator.BytesRefFieldComparatorSource; import org.elasticsearch.index.fielddata.ordinals.Ordinals; import org.elasticsearch.index.fielddata.ordinals.OrdinalsBuilder; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.indices.breaker.CircuitBreakerService; import org.elasticsearch.search.DocValueFormat; import org.elasticsearch.search.MultiValueMode; @@ -77,7 +76,7 @@ public Builder(String name, double minFrequency, double maxFrequency, int minSeg } @Override - public IndexOrdinalsFieldData build(IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) { + public IndexOrdinalsFieldData build(IndexFieldDataCache cache, CircuitBreakerService breakerService) { return new PagedBytesIndexFieldData(name, valuesSourceType, cache, breakerService, minFrequency, maxFrequency, minSegmentSize); } diff --git a/server/src/main/java/org/elasticsearch/index/fielddata/plain/SortedNumericIndexFieldData.java b/server/src/main/java/org/elasticsearch/index/fielddata/plain/SortedNumericIndexFieldData.java index 2847a5c6dbdf5..5dd82808d1952 100644 --- a/server/src/main/java/org/elasticsearch/index/fielddata/plain/SortedNumericIndexFieldData.java +++ b/server/src/main/java/org/elasticsearch/index/fielddata/plain/SortedNumericIndexFieldData.java @@ -39,7 +39,6 @@ import org.elasticsearch.index.fielddata.SortedNumericDoubleValues; import org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource; import org.elasticsearch.index.mapper.DocValueFetcher; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.indices.breaker.CircuitBreakerService; import org.elasticsearch.search.DocValueFormat; import org.elasticsearch.search.MultiValueMode; @@ -67,8 +66,7 @@ public Builder(String name, NumericType numericType) { @Override public SortedNumericIndexFieldData build( IndexFieldDataCache cache, - CircuitBreakerService breakerService, - MapperService mapperService + CircuitBreakerService breakerService ) { return new SortedNumericIndexFieldData(name, numericType); } diff --git a/server/src/main/java/org/elasticsearch/index/fielddata/plain/SortedSetOrdinalsIndexFieldData.java b/server/src/main/java/org/elasticsearch/index/fielddata/plain/SortedSetOrdinalsIndexFieldData.java index a405d449b6b63..8cf28854891d4 100644 --- a/server/src/main/java/org/elasticsearch/index/fielddata/plain/SortedSetOrdinalsIndexFieldData.java +++ b/server/src/main/java/org/elasticsearch/index/fielddata/plain/SortedSetOrdinalsIndexFieldData.java @@ -33,7 +33,6 @@ import org.elasticsearch.index.fielddata.LeafOrdinalsFieldData; import org.elasticsearch.index.fielddata.ScriptDocValues; import org.elasticsearch.index.fielddata.fieldcomparator.BytesRefFieldComparatorSource; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.indices.breaker.CircuitBreakerService; import org.elasticsearch.search.DocValueFormat; import org.elasticsearch.search.MultiValueMode; @@ -63,8 +62,7 @@ public Builder(String name, Function> scr @Override public SortedSetOrdinalsIndexFieldData build( IndexFieldDataCache cache, - CircuitBreakerService breakerService, - MapperService mapperService + CircuitBreakerService breakerService ) { return new SortedSetOrdinalsIndexFieldData(cache, name, valuesSourceType, breakerService, scriptFunction); } 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 770d7e0ea85e8..3605f7c3a3e27 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/IdFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/IdFieldMapper.java @@ -95,14 +95,15 @@ public static class Defaults { } } - public static final TypeParser PARSER = new FixedTypeParser(c -> new IdFieldMapper()); + public static final TypeParser PARSER = new FixedTypeParser(c -> new IdFieldMapper(() -> c.mapperService().isIdFieldDataEnabled())); static final class IdFieldType extends TermBasedFieldType { - public static final IdFieldType INSTANCE = new IdFieldType(); + private final Supplier fieldDataEnabled; - private IdFieldType() { + IdFieldType(Supplier fieldDataEnabled) { super(NAME, true, true, false, TextSearchInfo.SIMPLE_MATCH_ONLY, Collections.emptyMap()); + this.fieldDataEnabled = fieldDataEnabled; setIndexAnalyzer(Lucene.KEYWORD_ANALYZER); } @@ -148,6 +149,11 @@ public Query termsQuery(List values, QueryShardContext context) { @Override public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName, Supplier searchLookup) { + if (fieldDataEnabled.get() == false) { + throw new IllegalArgumentException("Fielddata access on the _id field is disallowed, " + + "you can re-enable it by updating the dynamic cluster setting: " + + IndicesService.INDICES_ID_FIELD_DATA_ENABLED_SETTING.getKey()); + } final IndexFieldData.Builder fieldDataBuilder = new PagedBytesIndexFieldData.Builder( name(), TextFieldMapper.Defaults.FIELDDATA_MIN_FREQUENCY, @@ -158,17 +164,11 @@ public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName, S @Override public IndexFieldData build( IndexFieldDataCache cache, - CircuitBreakerService breakerService, - MapperService mapperService + CircuitBreakerService breakerService ) { - if (mapperService.isIdFieldDataEnabled() == false) { - throw new IllegalArgumentException("Fielddata access on the _id field is disallowed, " - + "you can re-enable it by updating the dynamic cluster setting: " - + IndicesService.INDICES_ID_FIELD_DATA_ENABLED_SETTING.getKey()); - } deprecationLogger.deprecate("id_field_data", ID_FIELD_DATA_DEPRECATION_MESSAGE); final IndexFieldData fieldData = fieldDataBuilder.build(cache, - breakerService, mapperService); + breakerService); return new IndexFieldData<>() { @Override public String getFieldName() { @@ -256,12 +256,12 @@ public boolean advanceExact(int doc) throws IOException { }; } - private IdFieldMapper() { - super(new IdFieldType()); + private IdFieldMapper(Supplier fieldDataEnabled) { + super(new IdFieldType(fieldDataEnabled)); } @Override - public void preParse(ParseContext context) throws IOException { + public void preParse(ParseContext context) { BytesRef id = Uid.encodeId(context.sourceToParse().id()); context.doc().add(new Field(NAME, id, Defaults.FIELD_TYPE)); } @@ -270,5 +270,4 @@ public void preParse(ParseContext context) throws IOException { protected String contentType() { return CONTENT_TYPE; } - } 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 00be3a4b7c2ec..af594c30e7f97 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/IndexFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/IndexFieldMapper.java @@ -69,7 +69,7 @@ public Query existsQuery(QueryShardContext context) { @Override public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName, Supplier searchLookup) { - return new ConstantIndexFieldData.Builder(mapperService -> fullyQualifiedIndexName, name(), CoreValuesSourceType.BYTES); + return new ConstantIndexFieldData.Builder(fullyQualifiedIndexName, name(), CoreValuesSourceType.BYTES); } @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 267cc74d51f43..2126b388e27d2 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/TypeFieldType.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/TypeFieldType.java @@ -29,7 +29,6 @@ import org.elasticsearch.search.lookup.SearchLookup; import java.util.Collections; -import java.util.function.Function; import java.util.function.Supplier; /** @@ -65,9 +64,8 @@ public Query existsQuery(QueryShardContext context) { @Override public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName, Supplier searchLookup) { - Function typeFunction = mapperService -> type; deprecationLogger.deprecate("typefieldtype", TYPES_V7_DEPRECATION_MESSAGE); - return new ConstantIndexFieldData.Builder(typeFunction, name(), CoreValuesSourceType.BYTES); + return new ConstantIndexFieldData.Builder(type, name(), CoreValuesSourceType.BYTES); } @Override diff --git a/server/src/test/java/org/elasticsearch/index/fielddata/IndexFieldDataServiceTests.java b/server/src/test/java/org/elasticsearch/index/fielddata/IndexFieldDataServiceTests.java index 099be8fb10fcd..ee5670b32d561 100644 --- a/server/src/test/java/org/elasticsearch/index/fielddata/IndexFieldDataServiceTests.java +++ b/server/src/test/java/org/elasticsearch/index/fielddata/IndexFieldDataServiceTests.java @@ -126,7 +126,7 @@ public void testGetForFieldRuntimeField() { @SuppressWarnings("unchecked") Supplier searchLookup = (Supplier)invocationOnMock.getArguments()[1]; searchLookupSetOnce.set(searchLookup); - return (IndexFieldData.Builder) (cache, breakerService, mapperService) -> null; + return (IndexFieldData.Builder) (cache, breakerService) -> null; }); SearchLookup searchLookup = new SearchLookup(null, null); ifdService.getForField(ft, "qualified", () -> searchLookup); diff --git a/server/src/test/java/org/elasticsearch/index/mapper/IdFieldMapperTests.java b/server/src/test/java/org/elasticsearch/index/mapper/IdFieldMapperTests.java index fbf593df5fc5b..ecc4241fa5369 100644 --- a/server/src/test/java/org/elasticsearch/index/mapper/IdFieldMapperTests.java +++ b/server/src/test/java/org/elasticsearch/index/mapper/IdFieldMapperTests.java @@ -86,7 +86,7 @@ public void testEnableFieldData() throws IOException { IllegalArgumentException exc = expectThrows(IllegalArgumentException.class, () -> ft.fielddataBuilder("test", () -> { throw new UnsupportedOperationException(); - }).build(null, null, mapperService)); + }).build(null, null)); assertThat(exc.getMessage(), containsString(IndicesService.INDICES_ID_FIELD_DATA_ENABLED_SETTING.getKey())); client().admin().cluster().prepareUpdateSettings() @@ -95,7 +95,7 @@ public void testEnableFieldData() throws IOException { try { ft.fielddataBuilder("test", () -> { throw new UnsupportedOperationException(); - }).build(null, null, mapperService); + }).build(null, null); assertWarnings(ID_FIELD_DATA_DEPRECATION_MESSAGE); } finally { // unset cluster setting diff --git a/server/src/test/java/org/elasticsearch/index/mapper/IdFieldTypeTests.java b/server/src/test/java/org/elasticsearch/index/mapper/IdFieldTypeTests.java index 738e7acfdf6c6..878a16f1a2cca 100644 --- a/server/src/test/java/org/elasticsearch/index/mapper/IdFieldTypeTests.java +++ b/server/src/test/java/org/elasticsearch/index/mapper/IdFieldTypeTests.java @@ -32,13 +32,13 @@ public class IdFieldTypeTests extends ESTestCase { public void testRangeQuery() { - MappedFieldType ft = IdFieldMapper.IdFieldType.INSTANCE; + MappedFieldType ft = new IdFieldMapper.IdFieldType(() -> false); IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> ft.rangeQuery(null, null, randomBoolean(), randomBoolean(), null, null, null, null)); assertEquals("Field [_id] of type [_id] does not support range queries", e.getMessage()); } - public void testTermsQuery() throws Exception { + public void testTermsQuery() { QueryShardContext context = Mockito.mock(QueryShardContext.class); Settings indexSettings = Settings.builder() .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) @@ -53,7 +53,7 @@ public void testTermsQuery() throws Exception { MapperService mapperService = Mockito.mock(MapperService.class); Mockito.when(context.getMapperService()).thenReturn(mapperService); - MappedFieldType ft = IdFieldMapper.IdFieldType.INSTANCE; + MappedFieldType ft = new IdFieldMapper.IdFieldType(() -> false); Query query = ft.termQuery("id", context); assertEquals(new TermInSetQuery("_id", Uid.encodeId("id")), query); } diff --git a/server/src/test/java/org/elasticsearch/index/mapper/NumberFieldTypeTests.java b/server/src/test/java/org/elasticsearch/index/mapper/NumberFieldTypeTests.java index 5a91fe3d8754c..6f40d9443dc77 100644 --- a/server/src/test/java/org/elasticsearch/index/mapper/NumberFieldTypeTests.java +++ b/server/src/test/java/org/elasticsearch/index/mapper/NumberFieldTypeTests.java @@ -455,7 +455,7 @@ public void doTestIndexSortRangeQueries(NumberType type, Supplier valueS NumberFieldType fieldType = new NumberFieldType("field", type); IndexNumericFieldData fielddata = (IndexNumericFieldData) fieldType.fielddataBuilder("index", () -> { throw new UnsupportedOperationException(); - }).build(null, null, null); + }).build(null, null); SortField sortField = fielddata.sortField(null, MultiValueMode.MIN, null, randomBoolean()); IndexWriterConfig writerConfig = new IndexWriterConfig(); diff --git a/server/src/test/java/org/elasticsearch/index/mapper/TypeFieldTypeTests.java b/server/src/test/java/org/elasticsearch/index/mapper/TypeFieldTypeTests.java index f0ce7e1f17123..be613a5cda693 100644 --- a/server/src/test/java/org/elasticsearch/index/mapper/TypeFieldTypeTests.java +++ b/server/src/test/java/org/elasticsearch/index/mapper/TypeFieldTypeTests.java @@ -49,7 +49,7 @@ public void testDocValues() throws Exception { MappedFieldType ft = mapperService.fieldType(TypeFieldType.NAME); IndexOrdinalsFieldData fd = (IndexOrdinalsFieldData) ft.fielddataBuilder("test", () -> { throw new UnsupportedOperationException(); - }).build(new IndexFieldDataCache.None(), new NoneCircuitBreakerService(), mapperService); + }).build(new IndexFieldDataCache.None(), new NoneCircuitBreakerService()); LeafOrdinalsFieldData afd = fd.load(r.leaves().get(0)); SortedSetDocValues values = afd.getOrdinalsValues(); assertTrue(values.advanceExact(0)); diff --git a/server/src/test/java/org/elasticsearch/index/query/QueryShardContextTests.java b/server/src/test/java/org/elasticsearch/index/query/QueryShardContextTests.java index 4a83530490041..f25932f71d2e7 100644 --- a/server/src/test/java/org/elasticsearch/index/query/QueryShardContextTests.java +++ b/server/src/test/java/org/elasticsearch/index/query/QueryShardContextTests.java @@ -301,7 +301,7 @@ private static QueryShardContext createQueryShardContext(String indexUuid, Strin final long nowInMillis = randomNonNegativeLong(); return new QueryShardContext( 0, indexSettings, BigArrays.NON_RECYCLING_INSTANCE, null, - (mappedFieldType, idxName, searchLookup) -> mappedFieldType.fielddataBuilder(idxName, searchLookup).build(null, null, null), + (mappedFieldType, idxName, searchLookup) -> mappedFieldType.fielddataBuilder(idxName, searchLookup).build(null, null), mapperService, null, null, NamedXContentRegistry.EMPTY, new NamedWriteableRegistry(Collections.emptyList()), null, null, () -> nowInMillis, clusterAlias, null, () -> true, null); } @@ -341,7 +341,7 @@ public void setNextDocId(int docId) { return leafFieldData; }); IndexFieldData.Builder builder = mock(IndexFieldData.Builder.class); - when(builder.build(any(), any(), any())).thenAnswer(buildInv -> indexFieldData); + when(builder.build(any(), any())).thenAnswer(buildInv -> indexFieldData); return builder; }); return fieldType; diff --git a/server/src/test/java/org/elasticsearch/search/sort/AbstractSortTestCase.java b/server/src/test/java/org/elasticsearch/search/sort/AbstractSortTestCase.java index 9a778459e6367..b857a5018b630 100644 --- a/server/src/test/java/org/elasticsearch/search/sort/AbstractSortTestCase.java +++ b/server/src/test/java/org/elasticsearch/search/sort/AbstractSortTestCase.java @@ -199,7 +199,7 @@ protected final QueryShardContext createMockShardContext(IndexSearcher searcher) TriFunction, IndexFieldData> indexFieldDataLookup = (fieldType, fieldIndexName, searchLookup) -> { IndexFieldData.Builder builder = fieldType.fielddataBuilder(fieldIndexName, searchLookup); - return builder.build(new IndexFieldDataCache.None(), null, null); + return builder.build(new IndexFieldDataCache.None(), null); }; return new QueryShardContext(0, idxSettings, BigArrays.NON_RECYCLING_INSTANCE, bitsetFilterCache, indexFieldDataLookup, null, null, scriptService, xContentRegistry(), namedWriteableRegistry, null, searcher, diff --git a/test/framework/src/main/java/org/elasticsearch/index/mapper/MapperTestCase.java b/test/framework/src/main/java/org/elasticsearch/index/mapper/MapperTestCase.java index e28a856a61e79..190e5df9fbc8a 100644 --- a/test/framework/src/main/java/org/elasticsearch/index/mapper/MapperTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/index/mapper/MapperTestCase.java @@ -282,7 +282,7 @@ protected final List fetchFromDocValues(MapperService mapperService, MappedFi .fielddataBuilder("test", () -> { throw new UnsupportedOperationException(); }) - .build(new IndexFieldDataCache.None(), new NoneCircuitBreakerService(), mapperService); + .build(new IndexFieldDataCache.None(), new NoneCircuitBreakerService()); SetOnce> result = new SetOnce<>(); withLuceneIndex(mapperService, iw -> { iw.addDocument(mapperService.documentMapper().parse(source(b -> b.field(ft.name(), sourceValue))).rootDoc()); diff --git a/test/framework/src/main/java/org/elasticsearch/search/aggregations/AggregatorTestCase.java b/test/framework/src/main/java/org/elasticsearch/search/aggregations/AggregatorTestCase.java index 615fcfd409f91..f75934413352a 100644 --- a/test/framework/src/main/java/org/elasticsearch/search/aggregations/AggregatorTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/search/aggregations/AggregatorTestCase.java @@ -383,7 +383,7 @@ protected TriFunction, IndexFiel MapperService mapperService, CircuitBreakerService circuitBreakerService) { return (fieldType, s, searchLookup) -> fieldType.fielddataBuilder( mapperService.getIndexSettings().getIndex().getName(), searchLookup) - .build(new IndexFieldDataCache.None(), circuitBreakerService, mapperService); + .build(new IndexFieldDataCache.None(), circuitBreakerService); } /** @@ -707,7 +707,7 @@ public void testSupportedFieldTypes() throws IOException { private ValuesSourceType fieldToVST(MappedFieldType fieldType) { return fieldType.fielddataBuilder("", () -> { throw new UnsupportedOperationException(); - }).build(null, null, null).getValuesSourceType(); + }).build(null, null).getValuesSourceType(); } /** 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 26ad9df4427b7..03c443ed64ae1 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 @@ -151,7 +151,7 @@ protected Object parseSourceValue(Object value) { @Override public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName, Supplier searchLookup) { failIfNoDocValues(); - return (cache, breakerService, mapperService) -> new IndexHistogramFieldData(name(), AnalyticsValuesSourceType.HISTOGRAM) { + return (cache, breakerService) -> new IndexHistogramFieldData(name(), AnalyticsValuesSourceType.HISTOGRAM) { @Override public LeafHistogramFieldData load(LeafReaderContext context) { 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 ad3d4c52ec8be..dcc1413c41498 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 @@ -127,7 +127,7 @@ public String familyTypeName() { @Override public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName, Supplier searchLookup) { - return new ConstantIndexFieldData.Builder(mapperService -> value, name(), CoreValuesSourceType.BYTES); + return new ConstantIndexFieldData.Builder(value, name(), CoreValuesSourceType.BYTES); } @Override diff --git a/x-pack/plugin/mapper-flattened/src/main/java/org/elasticsearch/xpack/flattened/mapper/FlatObjectFieldMapper.java b/x-pack/plugin/mapper-flattened/src/main/java/org/elasticsearch/xpack/flattened/mapper/FlatObjectFieldMapper.java index bc7c8b7801ad5..7763b29fbc4f3 100644 --- a/x-pack/plugin/mapper-flattened/src/main/java/org/elasticsearch/xpack/flattened/mapper/FlatObjectFieldMapper.java +++ b/x-pack/plugin/mapper-flattened/src/main/java/org/elasticsearch/xpack/flattened/mapper/FlatObjectFieldMapper.java @@ -424,7 +424,7 @@ public static class Builder implements IndexFieldData.Builder { } @Override - public IndexFieldData build(IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) { + public IndexFieldData build(IndexFieldDataCache cache, CircuitBreakerService breakerService) { IndexOrdinalsFieldData delegate = new SortedSetOrdinalsIndexFieldData( cache, fieldName, valuesSourceType, breakerService, AbstractLeafOrdinalsFieldData.DEFAULT_SCRIPT_FUNCTION); return new KeyedFlatObjectFieldData(key, delegate); 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 fda5dc00e511c..8f2796232aeea 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 @@ -218,11 +218,11 @@ public Query rangeQuery(Object lowerTerm, Object upperTerm, boolean includeLower @Override public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName, Supplier searchLookup) { failIfNoDocValues(); - return (cache, breakerService, mapperService) -> { + return (cache, breakerService) -> { final IndexNumericFieldData signedLongValues = new SortedNumericIndexFieldData.Builder( name(), IndexNumericFieldData.NumericType.LONG - ).build(cache, breakerService, mapperService); + ).build(cache, breakerService); return new UnsignedLongIndexFieldData(signedLongValues); }; } diff --git a/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/fielddata/BooleanScriptFieldData.java b/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/fielddata/BooleanScriptFieldData.java index 7b31886f05845..f65298bb7e34a 100644 --- a/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/fielddata/BooleanScriptFieldData.java +++ b/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/fielddata/BooleanScriptFieldData.java @@ -13,7 +13,6 @@ import org.elasticsearch.index.fielddata.IndexFieldDataCache; import org.elasticsearch.index.fielddata.IndexNumericFieldData; import org.elasticsearch.index.fielddata.plain.LeafLongFieldData; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.indices.breaker.CircuitBreakerService; import org.elasticsearch.search.aggregations.support.CoreValuesSourceType; import org.elasticsearch.search.aggregations.support.ValuesSourceType; @@ -31,7 +30,7 @@ public Builder(String name, BooleanFieldScript.LeafFactory leafFactory) { } @Override - public BooleanScriptFieldData build(IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) { + public BooleanScriptFieldData build(IndexFieldDataCache cache, CircuitBreakerService breakerService) { return new BooleanScriptFieldData(name, leafFactory); } } diff --git a/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/fielddata/DateScriptFieldData.java b/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/fielddata/DateScriptFieldData.java index 7efa9c65935c8..e0bb106ee48db 100644 --- a/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/fielddata/DateScriptFieldData.java +++ b/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/fielddata/DateScriptFieldData.java @@ -13,7 +13,6 @@ import org.elasticsearch.index.fielddata.IndexFieldDataCache; import org.elasticsearch.index.fielddata.IndexNumericFieldData; import org.elasticsearch.index.fielddata.plain.LeafLongFieldData; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.indices.breaker.CircuitBreakerService; import org.elasticsearch.search.aggregations.support.CoreValuesSourceType; import org.elasticsearch.search.aggregations.support.ValuesSourceType; @@ -31,7 +30,7 @@ public Builder(String name, DateFieldScript.LeafFactory leafFactory) { } @Override - public DateScriptFieldData build(IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) { + public DateScriptFieldData build(IndexFieldDataCache cache, CircuitBreakerService breakerService) { return new DateScriptFieldData(name, leafFactory); } } diff --git a/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/fielddata/DoubleScriptFieldData.java b/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/fielddata/DoubleScriptFieldData.java index 6ed1ad55d8cb5..b03997adfba0a 100644 --- a/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/fielddata/DoubleScriptFieldData.java +++ b/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/fielddata/DoubleScriptFieldData.java @@ -13,7 +13,6 @@ import org.elasticsearch.index.fielddata.IndexNumericFieldData; import org.elasticsearch.index.fielddata.SortedNumericDoubleValues; import org.elasticsearch.index.fielddata.plain.LeafDoubleFieldData; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.indices.breaker.CircuitBreakerService; import org.elasticsearch.search.aggregations.support.CoreValuesSourceType; import org.elasticsearch.search.aggregations.support.ValuesSourceType; @@ -31,7 +30,7 @@ public Builder(String name, DoubleFieldScript.LeafFactory leafFactory) { } @Override - public DoubleScriptFieldData build(IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) { + public DoubleScriptFieldData build(IndexFieldDataCache cache, CircuitBreakerService breakerService) { return new DoubleScriptFieldData(name, leafFactory); } } diff --git a/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/fielddata/IpScriptFieldData.java b/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/fielddata/IpScriptFieldData.java index 70d8629de3e0d..99ff3a7939abd 100644 --- a/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/fielddata/IpScriptFieldData.java +++ b/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/fielddata/IpScriptFieldData.java @@ -17,7 +17,6 @@ import org.elasticsearch.index.fielddata.ScriptDocValues; import org.elasticsearch.index.fielddata.SortedBinaryDocValues; import org.elasticsearch.index.mapper.IpFieldMapper; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.indices.breaker.CircuitBreakerService; import org.elasticsearch.search.aggregations.support.CoreValuesSourceType; import org.elasticsearch.search.aggregations.support.ValuesSourceType; @@ -36,7 +35,7 @@ public Builder(String name, IpFieldScript.LeafFactory leafFactory) { } @Override - public IpScriptFieldData build(IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) { + public IpScriptFieldData build(IndexFieldDataCache cache, CircuitBreakerService breakerService) { return new IpScriptFieldData(name, leafFactory); } } diff --git a/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/fielddata/LongScriptFieldData.java b/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/fielddata/LongScriptFieldData.java index 7228d02113a8f..c58b75f622d19 100644 --- a/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/fielddata/LongScriptFieldData.java +++ b/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/fielddata/LongScriptFieldData.java @@ -13,7 +13,6 @@ import org.elasticsearch.index.fielddata.IndexFieldDataCache; import org.elasticsearch.index.fielddata.IndexNumericFieldData; import org.elasticsearch.index.fielddata.plain.LeafLongFieldData; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.indices.breaker.CircuitBreakerService; import org.elasticsearch.search.aggregations.support.CoreValuesSourceType; import org.elasticsearch.search.aggregations.support.ValuesSourceType; @@ -33,7 +32,7 @@ public Builder(String name, LongFieldScript.LeafFactory leafFactory) { } @Override - public LongScriptFieldData build(IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) { + public LongScriptFieldData build(IndexFieldDataCache cache, CircuitBreakerService breakerService) { return new LongScriptFieldData(name, leafFactory); } } diff --git a/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/fielddata/StringScriptFieldData.java b/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/fielddata/StringScriptFieldData.java index 8ada5c0e6133a..aaf03a9fd1130 100644 --- a/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/fielddata/StringScriptFieldData.java +++ b/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/fielddata/StringScriptFieldData.java @@ -11,7 +11,6 @@ import org.elasticsearch.index.fielddata.IndexFieldDataCache; import org.elasticsearch.index.fielddata.ScriptDocValues; import org.elasticsearch.index.fielddata.SortedBinaryDocValues; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.indices.breaker.CircuitBreakerService; import org.elasticsearch.search.aggregations.support.CoreValuesSourceType; import org.elasticsearch.search.aggregations.support.ValuesSourceType; @@ -28,7 +27,7 @@ public Builder(String name, StringFieldScript.LeafFactory leafFactory) { } @Override - public StringScriptFieldData build(IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) { + public StringScriptFieldData build(IndexFieldDataCache cache, CircuitBreakerService breakerService) { return new StringScriptFieldData(name, leafFactory); } } diff --git a/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/AbstractScriptFieldTypeTestCase.java b/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/AbstractScriptFieldTypeTestCase.java index 4a2eaf1a292ea..b0bf2b8f1f38d 100644 --- a/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/AbstractScriptFieldTypeTestCase.java +++ b/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/AbstractScriptFieldTypeTestCase.java @@ -79,7 +79,7 @@ protected static QueryShardContext mockContext(boolean allowExpensiveQueries, Ma when(context.allowExpensiveQueries()).thenReturn(allowExpensiveQueries); SearchLookup lookup = new SearchLookup( mapperService, - (mft, lookupSupplier) -> mft.fielddataBuilder("test", lookupSupplier).build(null, null, mapperService) + (mft, lookupSupplier) -> mft.fielddataBuilder("test", lookupSupplier).build(null, null) ); when(context.lookup()).thenReturn(lookup); return context; diff --git a/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/BooleanScriptFieldTypeTests.java b/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/BooleanScriptFieldTypeTests.java index b61c9b78bbee1..b0b25694889f3 100644 --- a/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/BooleanScriptFieldTypeTests.java +++ b/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/BooleanScriptFieldTypeTests.java @@ -76,7 +76,7 @@ public void testDocValues() throws IOException { try (DirectoryReader reader = iw.getReader()) { IndexSearcher searcher = newSearcher(reader); BooleanScriptFieldType ft = simpleMappedFieldType(); - BooleanScriptFieldData ifd = ft.fielddataBuilder("test", mockContext()::lookup).build(null, null, null); + BooleanScriptFieldData ifd = ft.fielddataBuilder("test", mockContext()::lookup).build(null, null); searcher.search(new MatchAllDocsQuery(), new Collector() { @Override public ScoreMode scoreMode() { @@ -113,8 +113,7 @@ public void testSort() throws IOException { iw.addDocument(List.of(new StoredField("_source", new BytesRef("{\"foo\": [false]}")))); try (DirectoryReader reader = iw.getReader()) { IndexSearcher searcher = newSearcher(reader); - BooleanScriptFieldData ifd = simpleMappedFieldType().fielddataBuilder("test", mockContext()::lookup) - .build(null, null, null); + BooleanScriptFieldData ifd = simpleMappedFieldType().fielddataBuilder("test", mockContext()::lookup).build(null, null); SortField sf = ifd.sortField(null, MultiValueMode.MIN, null, false); TopFieldDocs docs = searcher.search(new MatchAllDocsQuery(), 3, new Sort(sf)); assertThat(reader.document(docs.scoreDocs[0].doc).getBinaryValue("_source").utf8ToString(), equalTo("{\"foo\": [false]}")); diff --git a/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/DateScriptFieldTypeTests.java b/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/DateScriptFieldTypeTests.java index 4aa1dd576d536..1b1d5bebd51c7 100644 --- a/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/DateScriptFieldTypeTests.java +++ b/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/DateScriptFieldTypeTests.java @@ -106,7 +106,7 @@ public void testDocValues() throws IOException { try (DirectoryReader reader = iw.getReader()) { IndexSearcher searcher = newSearcher(reader); DateScriptFieldType ft = build("add_days", Map.of("days", 1)); - DateScriptFieldData ifd = ft.fielddataBuilder("test", mockContext()::lookup).build(null, null, null); + DateScriptFieldData ifd = ft.fielddataBuilder("test", mockContext()::lookup).build(null, null); searcher.search(new MatchAllDocsQuery(), new Collector() { @Override public ScoreMode scoreMode() { @@ -144,7 +144,7 @@ public void testSort() throws IOException { iw.addDocument(List.of(new StoredField("_source", new BytesRef("{\"timestamp\": [1595432181356]}")))); try (DirectoryReader reader = iw.getReader()) { IndexSearcher searcher = newSearcher(reader); - DateScriptFieldData ifd = simpleMappedFieldType().fielddataBuilder("test", mockContext()::lookup).build(null, null, null); + DateScriptFieldData ifd = simpleMappedFieldType().fielddataBuilder("test", mockContext()::lookup).build(null, null); SortField sf = ifd.sortField(null, MultiValueMode.MIN, null, false); TopFieldDocs docs = searcher.search(new MatchAllDocsQuery(), 3, new Sort(sf)); assertThat(readSource(reader, docs.scoreDocs[0].doc), equalTo("{\"timestamp\": [1595432181351]}")); diff --git a/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/DoubleScriptFieldTypeTests.java b/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/DoubleScriptFieldTypeTests.java index 09d8a3f8cc5c7..e264e232f7509 100644 --- a/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/DoubleScriptFieldTypeTests.java +++ b/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/DoubleScriptFieldTypeTests.java @@ -70,7 +70,7 @@ public void testDocValues() throws IOException { try (DirectoryReader reader = iw.getReader()) { IndexSearcher searcher = newSearcher(reader); DoubleScriptFieldType ft = build("add_param", Map.of("param", 1)); - DoubleScriptFieldData ifd = ft.fielddataBuilder("test", mockContext()::lookup).build(null, null, null); + DoubleScriptFieldData ifd = ft.fielddataBuilder("test", mockContext()::lookup).build(null, null); searcher.search(new MatchAllDocsQuery(), new Collector() { @Override public ScoreMode scoreMode() { @@ -108,7 +108,7 @@ public void testSort() throws IOException { iw.addDocument(List.of(new StoredField("_source", new BytesRef("{\"foo\": [2.1]}")))); try (DirectoryReader reader = iw.getReader()) { IndexSearcher searcher = newSearcher(reader); - DoubleScriptFieldData ifd = simpleMappedFieldType().fielddataBuilder("test", mockContext()::lookup).build(null, null, null); + DoubleScriptFieldData ifd = simpleMappedFieldType().fielddataBuilder("test", mockContext()::lookup).build(null, null); SortField sf = ifd.sortField(null, MultiValueMode.MIN, null, false); TopFieldDocs docs = searcher.search(new MatchAllDocsQuery(), 3, new Sort(sf)); assertThat(reader.document(docs.scoreDocs[0].doc).getBinaryValue("_source").utf8ToString(), equalTo("{\"foo\": [1.1]}")); diff --git a/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/IpScriptFieldTypeTests.java b/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/IpScriptFieldTypeTests.java index 0525282b8649d..5009620e1a8ba 100644 --- a/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/IpScriptFieldTypeTests.java +++ b/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/IpScriptFieldTypeTests.java @@ -72,7 +72,7 @@ public void testDocValues() throws IOException { try (DirectoryReader reader = iw.getReader()) { IndexSearcher searcher = newSearcher(reader); IpScriptFieldType ft = build("append_param", Map.of("param", ".1")); - BinaryScriptFieldData ifd = ft.fielddataBuilder("test", mockContext()::lookup).build(null, null, null); + BinaryScriptFieldData ifd = ft.fielddataBuilder("test", mockContext()::lookup).build(null, null); DocValueFormat format = ft.docValueFormat(null, null); searcher.search(new MatchAllDocsQuery(), new Collector() { @Override @@ -111,7 +111,7 @@ public void testSort() throws IOException { iw.addDocument(List.of(new StoredField("_source", new BytesRef("{\"foo\": [\"192.168.0.2\"]}")))); try (DirectoryReader reader = iw.getReader()) { IndexSearcher searcher = newSearcher(reader); - BinaryScriptFieldData ifd = simpleMappedFieldType().fielddataBuilder("test", mockContext()::lookup).build(null, null, null); + BinaryScriptFieldData ifd = simpleMappedFieldType().fielddataBuilder("test", mockContext()::lookup).build(null, null); SortField sf = ifd.sortField(null, MultiValueMode.MIN, null, false); TopFieldDocs docs = searcher.search(new MatchAllDocsQuery(), 3, new Sort(sf)); assertThat( diff --git a/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/KeywordScriptFieldTypeTests.java b/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/KeywordScriptFieldTypeTests.java index f0abab92a9321..3b74cee2fe1f1 100644 --- a/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/KeywordScriptFieldTypeTests.java +++ b/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/KeywordScriptFieldTypeTests.java @@ -65,7 +65,7 @@ public void testDocValues() throws IOException { try (DirectoryReader reader = iw.getReader()) { IndexSearcher searcher = newSearcher(reader); KeywordScriptFieldType ft = build("append_param", Map.of("param", "-suffix")); - StringScriptFieldData ifd = ft.fielddataBuilder("test", mockContext()::lookup).build(null, null, null); + StringScriptFieldData ifd = ft.fielddataBuilder("test", mockContext()::lookup).build(null, null); searcher.search(new MatchAllDocsQuery(), new Collector() { @Override public ScoreMode scoreMode() { @@ -103,7 +103,7 @@ public void testSort() throws IOException { iw.addDocument(List.of(new StoredField("_source", new BytesRef("{\"foo\": [\"b\"]}")))); try (DirectoryReader reader = iw.getReader()) { IndexSearcher searcher = newSearcher(reader); - BinaryScriptFieldData ifd = simpleMappedFieldType().fielddataBuilder("test", mockContext()::lookup).build(null, null, null); + BinaryScriptFieldData ifd = simpleMappedFieldType().fielddataBuilder("test", mockContext()::lookup).build(null, null); SortField sf = ifd.sortField(null, MultiValueMode.MIN, null, false); TopFieldDocs docs = searcher.search(new MatchAllDocsQuery(), 3, new Sort(sf)); assertThat(reader.document(docs.scoreDocs[0].doc).getBinaryValue("_source").utf8ToString(), equalTo("{\"foo\": [\"a\"]}")); diff --git a/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/LongScriptFieldTypeTests.java b/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/LongScriptFieldTypeTests.java index b23c9452491c2..16e38168a032f 100644 --- a/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/LongScriptFieldTypeTests.java +++ b/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/LongScriptFieldTypeTests.java @@ -69,7 +69,7 @@ public void testDocValues() throws IOException { try (DirectoryReader reader = iw.getReader()) { IndexSearcher searcher = newSearcher(reader); LongScriptFieldType ft = build("add_param", Map.of("param", 1)); - LongScriptFieldData ifd = ft.fielddataBuilder("test", mockContext()::lookup).build(null, null, null); + LongScriptFieldData ifd = ft.fielddataBuilder("test", mockContext()::lookup).build(null, null); searcher.search(new MatchAllDocsQuery(), new Collector() { @Override public ScoreMode scoreMode() { @@ -107,7 +107,7 @@ public void testSort() throws IOException { iw.addDocument(List.of(new StoredField("_source", new BytesRef("{\"foo\": [2]}")))); try (DirectoryReader reader = iw.getReader()) { IndexSearcher searcher = newSearcher(reader); - LongScriptFieldData ifd = simpleMappedFieldType().fielddataBuilder("test", mockContext()::lookup).build(null, null, null); + LongScriptFieldData ifd = simpleMappedFieldType().fielddataBuilder("test", mockContext()::lookup).build(null, null); SortField sf = ifd.sortField(null, MultiValueMode.MIN, null, false); TopFieldDocs docs = searcher.search(new MatchAllDocsQuery(), 3, new Sort(sf)); assertThat(reader.document(docs.scoreDocs[0].doc).getBinaryValue("_source").utf8ToString(), equalTo("{\"foo\": [1]}")); @@ -124,8 +124,7 @@ public void testNow() throws IOException { iw.addDocument(List.of(new StoredField("_source", new BytesRef("{\"timestamp\": [1595432181356]}")))); try (DirectoryReader reader = iw.getReader()) { IndexSearcher searcher = newSearcher(reader); - LongScriptFieldData ifd = build("millis_ago", Map.of()).fielddataBuilder("test", mockContext()::lookup) - .build(null, null, null); + LongScriptFieldData ifd = build("millis_ago", Map.of()).fielddataBuilder("test", mockContext()::lookup).build(null, null); SortField sf = ifd.sortField(null, MultiValueMode.MIN, null, false); TopFieldDocs docs = searcher.search(new MatchAllDocsQuery(), 3, new Sort(sf)); assertThat(readSource(reader, docs.scoreDocs[0].doc), equalTo("{\"timestamp\": [1595432181356]}")); diff --git a/x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/index/fielddata/AbstractLatLonShapeIndexFieldData.java b/x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/index/fielddata/AbstractLatLonShapeIndexFieldData.java index 3a59dd1181c9f..0dc41abfdf8de 100644 --- a/x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/index/fielddata/AbstractLatLonShapeIndexFieldData.java +++ b/x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/index/fielddata/AbstractLatLonShapeIndexFieldData.java @@ -15,7 +15,6 @@ import org.elasticsearch.common.util.BigArrays; import org.elasticsearch.index.fielddata.IndexFieldData; import org.elasticsearch.index.fielddata.IndexFieldDataCache; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.indices.breaker.CircuitBreakerService; import org.elasticsearch.search.DocValueFormat; import org.elasticsearch.search.MultiValueMode; @@ -97,7 +96,7 @@ public Builder(String name, ValuesSourceType valuesSourceType) { } @Override - public IndexFieldData build(IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) { + public IndexFieldData build(IndexFieldDataCache cache, CircuitBreakerService breakerService) { // ignore breaker return new LatLonShapeIndexFieldData(name, valuesSourceType); } diff --git a/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/query/VectorIndexFieldData.java b/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/query/VectorIndexFieldData.java index f7680e0068278..1cd539baa1a5a 100644 --- a/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/query/VectorIndexFieldData.java +++ b/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/query/VectorIndexFieldData.java @@ -14,7 +14,6 @@ import org.elasticsearch.index.fielddata.IndexFieldData; import org.elasticsearch.index.fielddata.IndexFieldData.XFieldComparatorSource.Nested; import org.elasticsearch.index.fielddata.IndexFieldDataCache; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.indices.breaker.CircuitBreakerService; import org.elasticsearch.search.DocValueFormat; import org.elasticsearch.search.MultiValueMode; @@ -74,7 +73,7 @@ public Builder(String name, ValuesSourceType valuesSourceType) { } @Override - public IndexFieldData build(IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) { + public IndexFieldData build(IndexFieldDataCache cache, CircuitBreakerService breakerService) { return new VectorIndexFieldData(name, valuesSourceType); } 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 7b91251fe1dbd..3a0371e4b5761 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 @@ -969,8 +969,7 @@ public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName, S @Override public IndexFieldData build( IndexFieldDataCache cache, - CircuitBreakerService breakerService, - MapperService mapperService + CircuitBreakerService breakerService ) { return new StringBinaryIndexFieldData(name(), CoreValuesSourceType.BYTES); } diff --git a/x-pack/plugin/wildcard/src/test/java/org/elasticsearch/xpack/wildcard/mapper/WildcardFieldMapperTests.java b/x-pack/plugin/wildcard/src/test/java/org/elasticsearch/xpack/wildcard/mapper/WildcardFieldMapperTests.java index 93a4bc6c5a4d0..a8a6f967f44d4 100644 --- a/x-pack/plugin/wildcard/src/test/java/org/elasticsearch/xpack/wildcard/mapper/WildcardFieldMapperTests.java +++ b/x-pack/plugin/wildcard/src/test/java/org/elasticsearch/xpack/wildcard/mapper/WildcardFieldMapperTests.java @@ -886,7 +886,7 @@ protected final QueryShardContext createMockShardContext() { TriFunction, IndexFieldData> indexFieldDataLookup = (fieldType, fieldIndexName, searchLookup) -> { IndexFieldData.Builder builder = fieldType.fielddataBuilder(fieldIndexName, searchLookup); - return builder.build(new IndexFieldDataCache.None(), null, null); + return builder.build(new IndexFieldDataCache.None(), null); }; return new QueryShardContext(0, idxSettings, BigArrays.NON_RECYCLING_INSTANCE, bitsetFilterCache, indexFieldDataLookup, null, null, null, xContentRegistry(), null, null, null,