Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@
/** Request the mappings of specific fields */
public class GetFieldMappingsRequest implements Validatable {

@Deprecated
private boolean local = false;

private String[] fields = Strings.EMPTY_ARRAY;

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

private IndicesOptions indicesOptions = IndicesOptions.strictExpandOpen();

/**
* Indicate whether the receiving node should operate based on local index information or forward requests,
* where needed, to other nodes. If running locally, request will not raise errors if running locally & missing indices.
*/
@Deprecated
public GetFieldMappingsRequest local(boolean local) {
this.local = local;
return this;
}

@Deprecated
public boolean local() {
return local;
}

public GetFieldMappingsRequest indices(String... indices) {
this.indices = indices;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -701,10 +701,6 @@ public void testGetFieldMapping() throws IOException, InterruptedException {
request.indicesOptions(IndicesOptions.lenientExpandOpen()); // <1>
// end::get-field-mappings-request-indicesOptions

// tag::get-field-mappings-request-local
request.local(true); // <1>
// end::get-field-mappings-request-local

{
// tag::get-field-mappings-execute
GetFieldMappingsResponse response =
Expand Down
9 changes: 0 additions & 9 deletions docs/java-rest/high-level/indices/get_field_mappings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,6 @@ include-tagged::{doc-tests-file}[{api}-request-indicesOptions]
<1> Setting `IndicesOptions` controls how unavailable indices are resolved and
how wildcard expressions are expanded

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

include::../execution.asciidoc[]

[id="{upid}-{api}-response"]
Expand Down
6 changes: 0 additions & 6 deletions docs/reference/indices/get-field-mapping.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@ include::{docdir}/rest-api/common-parms.asciidoc[tag=index-ignore-unavailable]
(Optional, boolean) If `true`, the response includes default mapping values.
Defaults to `false`.

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


[[get-field-mapping-api-example]]
==== {api-examples-title}
Expand Down
7 changes: 7 additions & 0 deletions docs/reference/migration/migrate_8_0/api.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,10 @@ to determine the nodes returned by the API rather than the cluster state from
the master, but this API requests information from each selected node
regardless of the `?local` parameter which means this API does not run in a
fully node-local fashion.

[float]
==== Deprecated `local` parameter removed from get field mapping API

The `local` parameter for get field mapping API was deprecated in 7.8 and is
removed in 8.0. This parameter is a no-op and field mappings are always retrieved
locally.
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,15 @@ setup:
- match: {test_index.mappings.text.mapping.text.analyzer: default}

---
"Get field mapping with local is deprecated":
"Get field mapping with local parameter should fail":

- skip:
features: ["warnings", "node_selector"]

- do:
catch: bad_request
node_selector:
version: "8.0.0 - "
warnings:
- "Use [local] in get field mapping requests is deprecated. The parameter will be removed in the next major version"
indices.get_field_mapping:
fields: text
local: true

- match: {test_index.mappings.text.mapping.text.type: text}
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@
*/
public class GetFieldMappingsRequest extends ActionRequest implements IndicesRequest.Replaceable {

protected boolean local = false;

private String[] fields = Strings.EMPTY_ARRAY;

private boolean includeDefaults = false;
Expand All @@ -59,26 +57,17 @@ public GetFieldMappingsRequest(StreamInput in) throws IOException {
if (types != Strings.EMPTY_ARRAY) {
throw new IllegalArgumentException("Expected empty type array but received [" + Arrays.toString(types) + "]");
}

}
indicesOptions = IndicesOptions.readIndicesOptions(in);
local = in.readBoolean();
// Consume the deprecated local parameter
if (in.getVersion().before(Version.V_8_0_0)) {
in.readBoolean();
}
Comment on lines +64 to +66
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not necessary if we can be sure that the request never goes across wire.

fields = in.readStringArray();
includeDefaults = in.readBoolean();
}

/**
* Indicate whether the receiving node should operate based on local index information or forward requests,
* where needed, to other nodes. If running locally, request will not raise errors if running locally &amp; missing indices.
*/
public GetFieldMappingsRequest local(boolean local) {
this.local = local;
return this;
}

public boolean local() {
return local;
}

@Override
public GetFieldMappingsRequest indices(String... indices) {
this.indices = indices;
Expand Down Expand Up @@ -133,7 +122,9 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeStringArray(Strings.EMPTY_ARRAY);
}
indicesOptions.writeIndicesOptions(out);
out.writeBoolean(local);
if (out.getVersion().before(Version.V_8_0_0)) {
out.writeBoolean(true);
}
Comment on lines +125 to +127
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here as well, not needed if the request never goes across nodes.

out.writeStringArray(fields);
out.writeBoolean(includeDefaults);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,12 @@

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

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsRequest;
import org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsResponse;
import org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsResponse.FieldMappingMetadata;
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.BytesRestResponse;
Expand All @@ -46,10 +43,6 @@

public class RestGetFieldMappingAction extends BaseRestHandler {

private static final Logger logger = LogManager.getLogger(RestGetFieldMappingAction.class);
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(logger);


@Override
public List<Route> routes() {
return List.of(
Expand All @@ -70,13 +63,6 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC
GetFieldMappingsRequest getMappingsRequest = new GetFieldMappingsRequest();
getMappingsRequest.indices(indices).fields(fields).includeDefaults(request.paramAsBoolean("include_defaults", false));
getMappingsRequest.indicesOptions(IndicesOptions.fromRequest(request, getMappingsRequest.indicesOptions()));

if (request.hasParam("local")) {
deprecationLogger.deprecatedAndMaybeLog("get_field_mapping_local",
"Use [local] in get field mapping requests is deprecated. "
+ "The parameter will be removed in the next major version");
}
getMappingsRequest.local(request.paramAsBoolean("local", getMappingsRequest.local()));
return channel ->
client.admin().indices().getFieldMappings(getMappingsRequest, new RestBuilderListener<>(channel) {
@Override
Expand Down