Skip to content

Commit 92427d3

Browse files
authored
Remove local parameter for get field mapping API (#55100)
The local parameter of get field mapping API is marked as deprecated in 7.x. This PR removes it for v8.0
1 parent 1fc05f1 commit 92427d3

File tree

8 files changed

+17
-73
lines changed

8 files changed

+17
-73
lines changed

client/rest-high-level/src/main/java/org/elasticsearch/client/indices/GetFieldMappingsRequest.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@
2626
/** Request the mappings of specific fields */
2727
public class GetFieldMappingsRequest implements Validatable {
2828

29-
@Deprecated
30-
private boolean local = false;
31-
3229
private String[] fields = Strings.EMPTY_ARRAY;
3330

3431
private boolean includeDefaults = false;
@@ -37,21 +34,6 @@ public class GetFieldMappingsRequest implements Validatable {
3734

3835
private IndicesOptions indicesOptions = IndicesOptions.strictExpandOpen();
3936

40-
/**
41-
* Indicate whether the receiving node should operate based on local index information or forward requests,
42-
* where needed, to other nodes. If running locally, request will not raise errors if running locally & missing indices.
43-
*/
44-
@Deprecated
45-
public GetFieldMappingsRequest local(boolean local) {
46-
this.local = local;
47-
return this;
48-
}
49-
50-
@Deprecated
51-
public boolean local() {
52-
return local;
53-
}
54-
5537
public GetFieldMappingsRequest indices(String... indices) {
5638
this.indices = indices;
5739
return this;

client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/IndicesClientDocumentationIT.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -701,10 +701,6 @@ public void testGetFieldMapping() throws IOException, InterruptedException {
701701
request.indicesOptions(IndicesOptions.lenientExpandOpen()); // <1>
702702
// end::get-field-mappings-request-indicesOptions
703703

704-
// tag::get-field-mappings-request-local
705-
request.local(true); // <1>
706-
// end::get-field-mappings-request-local
707-
708704
{
709705
// tag::get-field-mappings-execute
710706
GetFieldMappingsResponse response =

docs/java-rest/high-level/indices/get_field_mappings.asciidoc

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,6 @@ include-tagged::{doc-tests-file}[{api}-request-indicesOptions]
3030
<1> Setting `IndicesOptions` controls how unavailable indices are resolved and
3131
how wildcard expressions are expanded
3232

33-
["source","java",subs="attributes,callouts,macros"]
34-
--------------------------------------------------
35-
include-tagged::{doc-tests-file}[{api}-request-local]
36-
--------------------------------------------------
37-
<1> deprecated:[7.8.0, This parameter is a no-op and field mappings are always retrieved locally]
38-
The `local` flag (defaults to `false`) controls whether the aliases need
39-
to be looked up in the local cluster state or in the cluster state held by
40-
the elected master node
41-
4233
include::../execution.asciidoc[]
4334

4435
[id="{upid}-{api}-response"]

docs/reference/indices/get-field-mapping.asciidoc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,6 @@ include::{docdir}/rest-api/common-parms.asciidoc[tag=index-ignore-unavailable]
4848
(Optional, boolean) If `true`, the response includes default mapping values.
4949
Defaults to `false`.
5050

51-
`local`::
52-
deprecated:[7.8.0, This parameter is a no-op and field mappings are always retrieved locally]
53-
(Optional, boolean) If `true`, the request retrieves information from the local
54-
node only. Defaults to `false`, which means information is retrieved from
55-
the master node.
56-
5751

5852
[[get-field-mapping-api-example]]
5953
==== {api-examples-title}

docs/reference/migration/migrate_8_0/api.asciidoc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,10 @@ to determine the nodes returned by the API rather than the cluster state from
1717
the master, but this API requests information from each selected node
1818
regardless of the `?local` parameter which means this API does not run in a
1919
fully node-local fashion.
20+
21+
[float]
22+
==== Deprecated `local` parameter removed from get field mapping API
23+
24+
The `local` parameter for get field mapping API was deprecated in 7.8 and is
25+
removed in 8.0. This parameter is a no-op and field mappings are always retrieved
26+
locally.

rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_field_mapping/10_basic.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,15 @@ setup:
5252
- match: {test_index.mappings.text.mapping.text.analyzer: default}
5353

5454
---
55-
"Get field mapping with local is deprecated":
55+
"Get field mapping with local parameter should fail":
5656

5757
- skip:
5858
features: ["warnings", "node_selector"]
5959

6060
- do:
61+
catch: bad_request
6162
node_selector:
6263
version: "8.0.0 - "
63-
warnings:
64-
- "Use [local] in get field mapping requests is deprecated. The parameter will be removed in the next major version"
6564
indices.get_field_mapping:
6665
fields: text
6766
local: true
68-
69-
- match: {test_index.mappings.text.mapping.text.type: text}

server/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/GetFieldMappingsRequest.java

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@
3939
*/
4040
public class GetFieldMappingsRequest extends ActionRequest implements IndicesRequest.Replaceable {
4141

42-
protected boolean local = false;
43-
4442
private String[] fields = Strings.EMPTY_ARRAY;
4543

4644
private boolean includeDefaults = false;
@@ -59,26 +57,17 @@ public GetFieldMappingsRequest(StreamInput in) throws IOException {
5957
if (types != Strings.EMPTY_ARRAY) {
6058
throw new IllegalArgumentException("Expected empty type array but received [" + Arrays.toString(types) + "]");
6159
}
60+
6261
}
6362
indicesOptions = IndicesOptions.readIndicesOptions(in);
64-
local = in.readBoolean();
63+
// Consume the deprecated local parameter
64+
if (in.getVersion().before(Version.V_8_0_0)) {
65+
in.readBoolean();
66+
}
6567
fields = in.readStringArray();
6668
includeDefaults = in.readBoolean();
6769
}
6870

69-
/**
70-
* Indicate whether the receiving node should operate based on local index information or forward requests,
71-
* where needed, to other nodes. If running locally, request will not raise errors if running locally &amp; missing indices.
72-
*/
73-
public GetFieldMappingsRequest local(boolean local) {
74-
this.local = local;
75-
return this;
76-
}
77-
78-
public boolean local() {
79-
return local;
80-
}
81-
8271
@Override
8372
public GetFieldMappingsRequest indices(String... indices) {
8473
this.indices = indices;
@@ -133,7 +122,9 @@ public void writeTo(StreamOutput out) throws IOException {
133122
out.writeStringArray(Strings.EMPTY_ARRAY);
134123
}
135124
indicesOptions.writeIndicesOptions(out);
136-
out.writeBoolean(local);
125+
if (out.getVersion().before(Version.V_8_0_0)) {
126+
out.writeBoolean(true);
127+
}
137128
out.writeStringArray(fields);
138129
out.writeBoolean(includeDefaults);
139130
}

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

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,12 @@
1919

2020
package org.elasticsearch.rest.action.admin.indices;
2121

22-
import org.apache.logging.log4j.LogManager;
23-
import org.apache.logging.log4j.Logger;
2422
import org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsRequest;
2523
import org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsResponse;
2624
import org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsResponse.FieldMappingMetadata;
2725
import org.elasticsearch.action.support.IndicesOptions;
2826
import org.elasticsearch.client.node.NodeClient;
2927
import org.elasticsearch.common.Strings;
30-
import org.elasticsearch.common.logging.DeprecationLogger;
3128
import org.elasticsearch.common.xcontent.XContentBuilder;
3229
import org.elasticsearch.rest.BaseRestHandler;
3330
import org.elasticsearch.rest.BytesRestResponse;
@@ -46,10 +43,6 @@
4643

4744
public class RestGetFieldMappingAction extends BaseRestHandler {
4845

49-
private static final Logger logger = LogManager.getLogger(RestGetFieldMappingAction.class);
50-
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(logger);
51-
52-
5346
@Override
5447
public List<Route> routes() {
5548
return List.of(
@@ -70,13 +63,6 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC
7063
GetFieldMappingsRequest getMappingsRequest = new GetFieldMappingsRequest();
7164
getMappingsRequest.indices(indices).fields(fields).includeDefaults(request.paramAsBoolean("include_defaults", false));
7265
getMappingsRequest.indicesOptions(IndicesOptions.fromRequest(request, getMappingsRequest.indicesOptions()));
73-
74-
if (request.hasParam("local")) {
75-
deprecationLogger.deprecatedAndMaybeLog("get_field_mapping_local",
76-
"Use [local] in get field mapping requests is deprecated. "
77-
+ "The parameter will be removed in the next major version");
78-
}
79-
getMappingsRequest.local(request.paramAsBoolean("local", getMappingsRequest.local()));
8066
return channel ->
8167
client.admin().indices().getFieldMappings(getMappingsRequest, new RestBuilderListener<>(channel) {
8268
@Override

0 commit comments

Comments
 (0)