Skip to content

Commit 47211c0

Browse files
olcbeannik9000
authored andcommitted
REST: Clear Indices Cache API simplify param parsing (#29111)
Simplify the parsing of the params in Clear Indices Cache API, as a follow up to the removing of the deprecated parameter names.
1 parent 4d62640 commit 47211c0

File tree

2 files changed

+5
-24
lines changed

2 files changed

+5
-24
lines changed

server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterUpdateSettingsAction.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest;
2323
import org.elasticsearch.client.Requests;
2424
import org.elasticsearch.client.node.NodeClient;
25-
import org.elasticsearch.common.ParseField;
2625
import org.elasticsearch.common.settings.Settings;
2726
import org.elasticsearch.common.xcontent.XContentParser;
2827
import org.elasticsearch.rest.BaseRestHandler;

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

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@
2323
import org.elasticsearch.action.admin.indices.cache.clear.ClearIndicesCacheResponse;
2424
import org.elasticsearch.action.support.IndicesOptions;
2525
import org.elasticsearch.client.node.NodeClient;
26-
import org.elasticsearch.common.ParseField;
2726
import org.elasticsearch.common.Strings;
2827
import org.elasticsearch.common.settings.Settings;
29-
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
3028
import org.elasticsearch.common.xcontent.XContentBuilder;
3129
import org.elasticsearch.rest.BaseRestHandler;
3230
import org.elasticsearch.rest.BytesRestResponse;
@@ -36,14 +34,14 @@
3634
import org.elasticsearch.rest.action.RestBuilderListener;
3735

3836
import java.io.IOException;
39-
import java.util.Map;
4037

4138
import static org.elasticsearch.rest.RestRequest.Method.GET;
4239
import static org.elasticsearch.rest.RestRequest.Method.POST;
4340
import static org.elasticsearch.rest.RestStatus.OK;
4441
import static org.elasticsearch.rest.action.RestActions.buildBroadcastShardsHeader;
4542

4643
public class RestClearIndicesCacheAction extends BaseRestHandler {
44+
4745
public RestClearIndicesCacheAction(Settings settings, RestController controller) {
4846
super(settings);
4947
controller.registerHandler(POST, "/_cache/clear", this);
@@ -82,27 +80,11 @@ public boolean canTripCircuitBreaker() {
8280
}
8381

8482
public static ClearIndicesCacheRequest fromRequest(final RestRequest request, ClearIndicesCacheRequest clearIndicesCacheRequest) {
85-
86-
for (Map.Entry<String, String> entry : request.params().entrySet()) {
87-
if (Fields.QUERY.match(entry.getKey(), LoggingDeprecationHandler.INSTANCE)) {
88-
clearIndicesCacheRequest.queryCache(request.paramAsBoolean(entry.getKey(), clearIndicesCacheRequest.queryCache()));
89-
} else if (Fields.REQUEST.match(entry.getKey(), LoggingDeprecationHandler.INSTANCE)) {
90-
clearIndicesCacheRequest.requestCache(request.paramAsBoolean(entry.getKey(), clearIndicesCacheRequest.requestCache()));
91-
} else if (Fields.FIELDDATA.match(entry.getKey(), LoggingDeprecationHandler.INSTANCE)) {
92-
clearIndicesCacheRequest.fieldDataCache(request.paramAsBoolean(entry.getKey(), clearIndicesCacheRequest.fieldDataCache()));
93-
} else if (Fields.FIELDS.match(entry.getKey(), LoggingDeprecationHandler.INSTANCE)) {
94-
clearIndicesCacheRequest.fields(request.paramAsStringArray(entry.getKey(), clearIndicesCacheRequest.fields()));
95-
}
96-
}
97-
83+
clearIndicesCacheRequest.queryCache(request.paramAsBoolean("query", clearIndicesCacheRequest.queryCache()));
84+
clearIndicesCacheRequest.requestCache(request.paramAsBoolean("request", clearIndicesCacheRequest.requestCache()));
85+
clearIndicesCacheRequest.fieldDataCache(request.paramAsBoolean("fielddata", clearIndicesCacheRequest.fieldDataCache()));
86+
clearIndicesCacheRequest.fields(request.paramAsStringArray("fields", clearIndicesCacheRequest.fields()));
9887
return clearIndicesCacheRequest;
9988
}
10089

101-
public static class Fields {
102-
public static final ParseField QUERY = new ParseField("query");
103-
public static final ParseField REQUEST = new ParseField("request");
104-
public static final ParseField FIELDDATA = new ParseField("fielddata");
105-
public static final ParseField FIELDS = new ParseField("fields");
106-
}
107-
10890
}

0 commit comments

Comments
 (0)