Skip to content

Commit eac4731

Browse files
authored
[9.0] Clean up leftover reference of include_type_name (#118535)
The query param `include_type_name` has been removed in `8.x` and has been only accepted in rest compatibility mode (see [removal of types](https://www.elastic.co/guide/en/elasticsearch/reference/7.17/removal-of-types.html#_schedule_for_removal_of_mapping_types)). In `9.x` this is not necessary anymore, #114850 has handled the majority of the removals. We apply some extra cleaning in this PR.
1 parent d270158 commit eac4731

File tree

7 files changed

+1
-93
lines changed

7 files changed

+1
-93
lines changed

rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/indices.put_mapping/10_basic.yml

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -84,32 +84,6 @@
8484
- match: { error.type: "illegal_argument_exception" }
8585
- match: { error.reason: "Types cannot be provided in put mapping requests" }
8686

87-
---
88-
"Put mappings with explicit _doc type bwc":
89-
- skip:
90-
cluster_features: [ "gte_v8.0.0"]
91-
reason: "old deprecation message for pre 8.0"
92-
- requires:
93-
test_runner_features: ["node_selector"]
94-
- do:
95-
indices.create:
96-
index: test_index
97-
98-
- do:
99-
node_selector:
100-
version: "original"
101-
catch: bad_request
102-
indices.put_mapping:
103-
index: test_index
104-
body:
105-
_doc:
106-
properties:
107-
field:
108-
type: keyword
109-
110-
- match: { error.type: "illegal_argument_exception" }
111-
- match: { error.reason: "Types cannot be provided in put mapping requests, unless the include_type_name parameter is set to true." }
112-
11387
---
11488
"Update per-field metadata":
11589

server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestCreateIndexAction.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,7 @@ static Map<String, Object> prepareMappings(Map<String, Object> source) {
7878
Map<String, Object> mappings = (Map<String, Object>) source.get("mappings");
7979
if (MapperService.isMappingSourceTyped(MapperService.SINGLE_MAPPING_NAME, mappings)) {
8080
throw new IllegalArgumentException(
81-
"The mapping definition cannot be nested under a type "
82-
+ "["
83-
+ MapperService.SINGLE_MAPPING_NAME
84-
+ "] unless include_type_name is set to true."
81+
"The mapping definition cannot be nested under a type [" + MapperService.SINGLE_MAPPING_NAME + "]."
8582
);
8683
}
8784

server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetFieldMappingAction.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,12 @@
99

1010
package org.elasticsearch.rest.action.admin.indices;
1111

12-
import org.apache.logging.log4j.LogManager;
13-
import org.apache.logging.log4j.Logger;
1412
import org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsRequest;
1513
import org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsResponse;
1614
import org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsResponse.FieldMappingMetadata;
1715
import org.elasticsearch.action.support.IndicesOptions;
1816
import org.elasticsearch.client.internal.node.NodeClient;
1917
import org.elasticsearch.common.Strings;
20-
import org.elasticsearch.common.logging.DeprecationLogger;
2118
import org.elasticsearch.rest.BaseRestHandler;
2219
import org.elasticsearch.rest.RestRequest;
2320
import org.elasticsearch.rest.RestResponse;
@@ -35,13 +32,6 @@
3532

3633
public class RestGetFieldMappingAction extends BaseRestHandler {
3734

38-
private static final Logger logger = LogManager.getLogger(RestGetFieldMappingAction.class);
39-
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(logger.getName());
40-
public static final String INCLUDE_TYPE_DEPRECATION_MESSAGE = "[types removal] Using include_type_name in get "
41-
+ "field mapping requests is deprecated. The parameter will be removed in the next major version.";
42-
public static final String TYPES_DEPRECATION_MESSAGE = "[types removal] Specifying types in get field mapping request is deprecated. "
43-
+ "Use typeless api instead";
44-
4535
@Override
4636
public List<Route> routes() {
4737
return List.of(new Route(GET, "/_mapping/field/{fields}"), new Route(GET, "/{index}/_mapping/field/{fields}"));

server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetIndicesAction.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import org.elasticsearch.action.support.IndicesOptions;
1414
import org.elasticsearch.client.internal.node.NodeClient;
1515
import org.elasticsearch.common.Strings;
16-
import org.elasticsearch.common.logging.DeprecationLogger;
1716
import org.elasticsearch.common.settings.Settings;
1817
import org.elasticsearch.rest.BaseRestHandler;
1918
import org.elasticsearch.rest.RestRequest;
@@ -35,9 +34,6 @@
3534
*/
3635
@ServerlessScope(Scope.PUBLIC)
3736
public class RestGetIndicesAction extends BaseRestHandler {
38-
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestGetIndicesAction.class);
39-
public static final String TYPES_DEPRECATION_MESSAGE = "[types removal] Using `include_type_name` in get indices requests"
40-
+ " is deprecated. The parameter will be removed in the next major version.";
4137

4238
@Override
4339
public List<Route> routes() {

server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetMappingAction.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import org.elasticsearch.action.support.IndicesOptions;
1414
import org.elasticsearch.client.internal.node.NodeClient;
1515
import org.elasticsearch.common.Strings;
16-
import org.elasticsearch.common.logging.DeprecationLogger;
1716
import org.elasticsearch.core.TimeValue;
1817
import org.elasticsearch.http.HttpChannel;
1918
import org.elasticsearch.rest.BaseRestHandler;
@@ -31,11 +30,6 @@
3130

3231
@ServerlessScope(Scope.PUBLIC)
3332
public class RestGetMappingAction extends BaseRestHandler {
34-
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestGetMappingAction.class);
35-
public static final String INCLUDE_TYPE_DEPRECATION_MSG = "[types removal] Using include_type_name in get"
36-
+ " mapping requests is deprecated. The parameter will be removed in the next major version.";
37-
public static final String TYPES_DEPRECATION_MESSAGE = "[types removal] Specifying types in get mapping request is deprecated. "
38-
+ "Use typeless api instead";
3933

4034
public RestGetMappingAction() {}
4135

server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestRolloverIndexAction.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import org.elasticsearch.action.support.IndicesOptions;
1515
import org.elasticsearch.client.internal.node.NodeClient;
1616
import org.elasticsearch.cluster.metadata.DataStream;
17-
import org.elasticsearch.common.logging.DeprecationLogger;
1817
import org.elasticsearch.rest.BaseRestHandler;
1918
import org.elasticsearch.rest.RestRequest;
2019
import org.elasticsearch.rest.Scope;
@@ -33,10 +32,6 @@
3332
@ServerlessScope(Scope.PUBLIC)
3433
public class RestRolloverIndexAction extends BaseRestHandler {
3534

36-
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestRolloverIndexAction.class);
37-
public static final String TYPES_DEPRECATION_MESSAGE = "[types removal] Using include_type_name in rollover "
38-
+ "index requests is deprecated. The parameter will be removed in the next major version.";
39-
4035
@Override
4136
public List<Route> routes() {
4237
return List.of(new Route(POST, "/{index}/_rollover"), new Route(POST, "/{index}/_rollover/{new_index}"));

server/src/test/java/org/elasticsearch/action/admin/indices/mapping/get/GetFieldMappingsResponseTests.java

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,16 @@
1212
import org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsResponse.FieldMappingMetadata;
1313
import org.elasticsearch.common.Strings;
1414
import org.elasticsearch.common.bytes.BytesArray;
15-
import org.elasticsearch.common.bytes.BytesReference;
1615
import org.elasticsearch.common.io.stream.BytesStreamOutput;
1716
import org.elasticsearch.common.io.stream.StreamInput;
1817
import org.elasticsearch.common.io.stream.Writeable;
19-
import org.elasticsearch.core.RestApiVersion;
2018
import org.elasticsearch.test.AbstractWireSerializingTestCase;
21-
import org.elasticsearch.xcontent.ToXContent;
22-
import org.elasticsearch.xcontent.XContentBuilder;
23-
import org.elasticsearch.xcontent.XContentParser;
24-
import org.elasticsearch.xcontent.json.JsonXContent;
2519

2620
import java.io.IOException;
2721
import java.util.Collections;
2822
import java.util.HashMap;
2923
import java.util.Map;
3024

31-
import static org.hamcrest.Matchers.hasKey;
32-
3325
public class GetFieldMappingsResponseTests extends AbstractWireSerializingTestCase<GetFieldMappingsResponse> {
3426

3527
public void testManualSerialization() throws IOException {
@@ -56,36 +48,6 @@ public void testNullFieldMappingToXContent() {
5648
assertEquals("{\"index\":{\"mappings\":{}}}", Strings.toString(response));
5749
}
5850

59-
public void testToXContentIncludesType() throws Exception {
60-
Map<String, Map<String, FieldMappingMetadata>> mappings = new HashMap<>();
61-
FieldMappingMetadata fieldMappingMetadata = new FieldMappingMetadata("my field", new BytesArray("{}"));
62-
mappings.put("index", Collections.singletonMap("field", fieldMappingMetadata));
63-
GetFieldMappingsResponse response = new GetFieldMappingsResponse(mappings);
64-
ToXContent.Params params = new ToXContent.MapParams(Collections.singletonMap("include_type_name", "true"));
65-
66-
// v8 does not have _doc, even when include_type_name is present
67-
// (although this throws unconsumed parameter exception in RestGetFieldMappingsAction)
68-
try (XContentBuilder builder = XContentBuilder.builder(JsonXContent.jsonXContent, RestApiVersion.V_8)) {
69-
response.toXContent(builder, params);
70-
71-
try (XContentParser parser = createParser(JsonXContent.jsonXContent, BytesReference.bytes(builder))) {
72-
@SuppressWarnings("unchecked")
73-
Map<String, Map<String, Object>> index = (Map<String, Map<String, Object>>) parser.map().get("index");
74-
assertThat(index.get("mappings"), hasKey("field"));
75-
}
76-
}
77-
78-
try (XContentBuilder builder = XContentBuilder.builder(JsonXContent.jsonXContent, RestApiVersion.V_8)) {
79-
response.toXContent(builder, ToXContent.EMPTY_PARAMS);
80-
81-
try (XContentParser parser = createParser(JsonXContent.jsonXContent, BytesReference.bytes(builder))) {
82-
@SuppressWarnings("unchecked")
83-
Map<String, Map<String, Object>> index = (Map<String, Map<String, Object>>) parser.map().get("index");
84-
assertThat(index.get("mappings"), hasKey("field"));
85-
}
86-
}
87-
}
88-
8951
@Override
9052
protected GetFieldMappingsResponse createTestInstance() {
9153
return new GetFieldMappingsResponse(randomMapping());

0 commit comments

Comments
 (0)