Skip to content

Commit 8a7491c

Browse files
authored
Remove support for type, fields, copy_to and boost in metadata field definition (#116944)
Support for type, fields, copy_to and boost in metadata field definition has been deprecated in #90989. Such fields have been long parsed and silently ignored.
1 parent 286c4bb commit 8a7491c

File tree

3 files changed

+11
-68
lines changed

3 files changed

+11
-68
lines changed

docs/changelog/116944.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
pr: 116944
2+
summary: "Remove support for type, fields, `copy_to` and boost in metadata field definition"
3+
area: Mapping
4+
type: breaking
5+
issues: []
6+
breaking:
7+
title: "Remove support for type, fields, copy_to and boost in metadata field definition"
8+
area: Mapping
9+
details: The type, fields, copy_to and boost parameters are no longer supported in metadata field definition
10+
impact: Users providing type, fields, copy_to or boost as part of metadata field definition should remove them from their mappings.
11+
notable: false

server/src/main/java/org/elasticsearch/index/mapper/MetadataFieldMapper.java

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,13 @@
1010
package org.elasticsearch.index.mapper;
1111

1212
import org.elasticsearch.common.Explicit;
13-
import org.elasticsearch.common.logging.DeprecationCategory;
1413
import org.elasticsearch.common.util.Maps;
1514
import org.elasticsearch.common.xcontent.support.XContentMapValues;
16-
import org.elasticsearch.index.IndexVersions;
1715
import org.elasticsearch.xcontent.XContentBuilder;
1816

1917
import java.io.IOException;
2018
import java.util.Iterator;
2119
import java.util.Map;
22-
import java.util.Set;
2320
import java.util.function.Function;
2421

2522
/**
@@ -135,8 +132,6 @@ public final MetadataFieldMapper build(MapperBuilderContext context) {
135132
return build();
136133
}
137134

138-
private static final Set<String> UNSUPPORTED_PARAMETERS_8_6_0 = Set.of("type", "fields", "copy_to", "boost");
139-
140135
public final void parseMetadataField(String name, MappingParserContext parserContext, Map<String, Object> fieldNode) {
141136
final Parameter<?>[] params = getParameters();
142137
Map<String, Parameter<?>> paramsMap = Maps.newHashMapWithExpectedSize(params.length);
@@ -149,20 +144,6 @@ public final void parseMetadataField(String name, MappingParserContext parserCon
149144
final Object propNode = entry.getValue();
150145
Parameter<?> parameter = paramsMap.get(propName);
151146
if (parameter == null) {
152-
if (UNSUPPORTED_PARAMETERS_8_6_0.contains(propName)) {
153-
if (parserContext.indexVersionCreated().onOrAfter(IndexVersions.V_8_6_0)) {
154-
// silently ignore type, and a few other parameters: sadly we've been doing this for a long time
155-
deprecationLogger.warn(
156-
DeprecationCategory.API,
157-
propName,
158-
"Parameter [{}] has no effect on metadata field [{}] and will be removed in future",
159-
propName,
160-
name
161-
);
162-
}
163-
iterator.remove();
164-
continue;
165-
}
166147
throw new MapperParsingException("unknown parameter [" + propName + "] on metadata field [" + name + "]");
167148
}
168149
parameter.parse(name, parserContext, propNode);

test/framework/src/main/java/org/elasticsearch/index/mapper/MetadataMapperTestCase.java

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import org.elasticsearch.common.compress.CompressedXContent;
1313
import org.elasticsearch.core.CheckedConsumer;
1414
import org.elasticsearch.index.IndexVersion;
15-
import org.elasticsearch.index.IndexVersions;
1615
import org.elasticsearch.index.mapper.MapperService.MergeReason;
1716
import org.elasticsearch.test.index.IndexVersionUtils;
1817
import org.elasticsearch.xcontent.XContentBuilder;
@@ -142,52 +141,4 @@ public final void testFixedMetaFieldsAreNotConfigurable() throws IOException {
142141
);
143142
assertEquals("Failed to parse mapping: " + fieldName() + " is not configurable", exception.getMessage());
144143
}
145-
146-
public void testTypeAndFriendsAreSilentlyIgnoredBefore_8_6_0() throws IOException {
147-
assumeTrue("Metadata field " + fieldName() + " isn't configurable", isConfigurable());
148-
IndexVersion previousVersion = IndexVersionUtils.getPreviousVersion(IndexVersions.V_8_6_0);
149-
IndexVersion version = IndexVersionUtils.randomVersionBetween(random(), IndexVersions.MINIMUM_COMPATIBLE, previousVersion);
150-
assumeTrue("Metadata field " + fieldName() + " is not supported on version " + version, isSupportedOn(version));
151-
MapperService mapperService = createMapperService(version, mapping(b -> {}));
152-
// these parameters were previously silently ignored, they will still be ignored in existing indices
153-
String[] unsupportedParameters = new String[] { "fields", "copy_to", "boost", "type" };
154-
for (String param : unsupportedParameters) {
155-
String mappingAsString = "{\n"
156-
+ " \"_doc\" : {\n"
157-
+ " \""
158-
+ fieldName()
159-
+ "\" : {\n"
160-
+ " \""
161-
+ param
162-
+ "\" : \"any\"\n"
163-
+ " }\n"
164-
+ " }\n"
165-
+ "}";
166-
assertNotNull(mapperService.parseMapping("_doc", MergeReason.MAPPING_UPDATE, new CompressedXContent(mappingAsString)));
167-
}
168-
}
169-
170-
public void testTypeAndFriendsAreDeprecatedFrom_8_6_0() throws IOException {
171-
assumeTrue("Metadata field " + fieldName() + " isn't configurable", isConfigurable());
172-
IndexVersion version = IndexVersionUtils.randomVersionBetween(random(), IndexVersions.V_8_6_0, IndexVersion.current());
173-
assumeTrue("Metadata field " + fieldName() + " is not supported on version " + version, isSupportedOn(version));
174-
MapperService mapperService = createMapperService(version, mapping(b -> {}));
175-
// these parameters were previously silently ignored, they are now deprecated in new indices
176-
String[] unsupportedParameters = new String[] { "fields", "copy_to", "boost", "type" };
177-
for (String param : unsupportedParameters) {
178-
String mappingAsString = "{\n"
179-
+ " \"_doc\" : {\n"
180-
+ " \""
181-
+ fieldName()
182-
+ "\" : {\n"
183-
+ " \""
184-
+ param
185-
+ "\" : \"any\"\n"
186-
+ " }\n"
187-
+ " }\n"
188-
+ "}";
189-
assertNotNull(mapperService.parseMapping("_doc", MergeReason.MAPPING_UPDATE, new CompressedXContent(mappingAsString)));
190-
assertWarnings("Parameter [" + param + "] has no effect on metadata field [" + fieldName() + "] and will be removed in future");
191-
}
192-
}
193144
}

0 commit comments

Comments
 (0)