|
23 | 23 | import org.elasticsearch.action.admin.indices.cache.clear.ClearIndicesCacheResponse; |
24 | 24 | import org.elasticsearch.action.support.IndicesOptions; |
25 | 25 | import org.elasticsearch.client.node.NodeClient; |
26 | | -import org.elasticsearch.common.ParseField; |
27 | 26 | import org.elasticsearch.common.Strings; |
28 | 27 | import org.elasticsearch.common.settings.Settings; |
29 | | -import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; |
30 | 28 | import org.elasticsearch.common.xcontent.XContentBuilder; |
31 | 29 | import org.elasticsearch.rest.BaseRestHandler; |
32 | 30 | import org.elasticsearch.rest.BytesRestResponse; |
|
36 | 34 | import org.elasticsearch.rest.action.RestBuilderListener; |
37 | 35 |
|
38 | 36 | import java.io.IOException; |
39 | | -import java.util.Map; |
40 | 37 |
|
41 | 38 | import static org.elasticsearch.rest.RestRequest.Method.GET; |
42 | 39 | import static org.elasticsearch.rest.RestRequest.Method.POST; |
43 | 40 | import static org.elasticsearch.rest.RestStatus.OK; |
44 | 41 | import static org.elasticsearch.rest.action.RestActions.buildBroadcastShardsHeader; |
45 | 42 |
|
46 | 43 | public class RestClearIndicesCacheAction extends BaseRestHandler { |
| 44 | + |
47 | 45 | public RestClearIndicesCacheAction(Settings settings, RestController controller) { |
48 | 46 | super(settings); |
49 | 47 | controller.registerHandler(POST, "/_cache/clear", this); |
@@ -82,27 +80,11 @@ public boolean canTripCircuitBreaker() { |
82 | 80 | } |
83 | 81 |
|
84 | 82 | 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())); |
98 | 87 | return clearIndicesCacheRequest; |
99 | 88 | } |
100 | 89 |
|
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 | | - |
108 | 90 | } |
0 commit comments