Skip to content

Commit 2d8d230

Browse files
StefanGornik9000
authored andcommitted
Deprecate request_cache for clear-cache (#23638)
It is called `request` now.
1 parent a5a9ac9 commit 2d8d230

File tree

5 files changed

+68
-3
lines changed

5 files changed

+68
-3
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public static ClearIndicesCacheRequest fromRequest(final RestRequest request, Cl
8181
if (Fields.QUERY.match(entry.getKey())) {
8282
clearIndicesCacheRequest.queryCache(request.paramAsBoolean(entry.getKey(), clearIndicesCacheRequest.queryCache()));
8383
}
84-
if (Fields.REQUEST_CACHE.match(entry.getKey())) {
84+
if (Fields.REQUEST.match(entry.getKey())) {
8585
clearIndicesCacheRequest.requestCache(request.paramAsBoolean(entry.getKey(), clearIndicesCacheRequest.requestCache()));
8686
}
8787
if (Fields.FIELD_DATA.match(entry.getKey())) {
@@ -100,7 +100,7 @@ public static ClearIndicesCacheRequest fromRequest(final RestRequest request, Cl
100100

101101
public static class Fields {
102102
public static final ParseField QUERY = new ParseField("query", "filter", "filter_cache");
103-
public static final ParseField REQUEST_CACHE = new ParseField("request_cache");
103+
public static final ParseField REQUEST = new ParseField("request", "request_cache");
104104
public static final ParseField FIELD_DATA = new ParseField("field_data", "fielddata");
105105
public static final ParseField RECYCLER = new ParseField("recycler");
106106
public static final ParseField FIELDS = new ParseField("fields");
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Licensed to Elasticsearch under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.elasticsearch.rest.action.admin.indices;
21+
22+
import org.elasticsearch.action.admin.indices.cache.clear.ClearIndicesCacheRequest;
23+
import org.elasticsearch.rest.RestRequest;
24+
import org.elasticsearch.test.ESTestCase;
25+
import org.elasticsearch.test.rest.FakeRestRequest;
26+
27+
import java.util.HashMap;
28+
29+
import static org.hamcrest.Matchers.equalTo;
30+
31+
public class RestClearIndicesCacheActionTests extends ESTestCase {
32+
33+
public void testRequestCacheSet() throws Exception {
34+
final HashMap<String, String> params = new HashMap<>();
35+
params.put("request", "true");
36+
final RestRequest restRequest = new FakeRestRequest.Builder(xContentRegistry())
37+
.withParams(params).build();
38+
ClearIndicesCacheRequest cacheRequest = new ClearIndicesCacheRequest();
39+
cacheRequest = RestClearIndicesCacheAction.fromRequest(restRequest, cacheRequest);
40+
assertThat(cacheRequest.requestCache(), equalTo(true));
41+
}
42+
}

docs/reference/modules/indices/request_cache.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ The cache can be expired manually with the <<indices-clearcache,`clear-cache` AP
4242

4343
[source,js]
4444
------------------------
45-
POST /kimchy,elasticsearch/_cache/clear?request_cache=true
45+
POST /kimchy,elasticsearch/_cache/clear?request=true
4646
------------------------
4747
// CONSOLE
4848
// TEST[s/^/PUT kimchy\nPUT elasticsearch\n/]

rest-api-spec/src/main/resources/rest-api-spec/api/indices.clear_cache.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@
5050
"type" : "boolean",
5151
"description" : "Clear the recycler cache"
5252
},
53+
"request_cache": {
54+
"type" : "boolean",
55+
"description" : "Clear request cache"
56+
},
5357
"request": {
5458
"type" : "boolean",
5559
"description" : "Clear request cache"

rest-api-spec/src/main/resources/rest-api-spec/test/indices.clear_cache/10_basic.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,22 @@
22
"clear_cache test":
33
- do:
44
indices.clear_cache: {}
5+
6+
---
7+
"clear_cache with request set to false":
8+
- do:
9+
indices.clear_cache:
10+
request: false
11+
12+
---
13+
"clear_cache with request_cache set to false":
14+
- skip:
15+
version: " - 5.3.99"
16+
reason: deprecation was added in 5.4.0
17+
features: "warnings"
18+
19+
- do:
20+
warnings:
21+
- 'Deprecated field [request_cache] used, expected [request] instead'
22+
indices.clear_cache:
23+
request_cache: false

0 commit comments

Comments
 (0)