Allow passing single scrollID in clear scroll API body (#24242)
* Allow single scrollId in string format Closes #24233
This commit is contained in:
parent
88de33d43d
commit
739cb35d1b
|
@ -78,13 +78,20 @@ public class RestClearScrollAction extends BaseRestHandler {
|
|||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||
if (token == XContentParser.Token.FIELD_NAME) {
|
||||
currentFieldName = parser.currentName();
|
||||
} else if ("scroll_id".equals(currentFieldName) && token == XContentParser.Token.START_ARRAY) {
|
||||
} else if ("scroll_id".equals(currentFieldName)){
|
||||
if (token == XContentParser.Token.START_ARRAY) {
|
||||
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
|
||||
if (token.isValue() == false) {
|
||||
throw new IllegalArgumentException("scroll_id array element should only contain scroll_id");
|
||||
}
|
||||
clearScrollRequest.addScrollId(parser.text());
|
||||
}
|
||||
} else {
|
||||
if (token.isValue() == false) {
|
||||
throw new IllegalArgumentException("scroll_id element should only contain scroll_id");
|
||||
}
|
||||
clearScrollRequest.addScrollId(parser.text());
|
||||
}
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unknown parameter [" + currentFieldName
|
||||
+ "] in request body or parameter is of the wrong type[" + token + "] ");
|
||||
|
|
|
@ -144,7 +144,7 @@ cleared as soon as the scroll is not being used anymore using the
|
|||
---------------------------------------
|
||||
DELETE /_search/scroll
|
||||
{
|
||||
"scroll_id" : ["DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ=="]
|
||||
"scroll_id" : "DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ=="
|
||||
}
|
||||
---------------------------------------
|
||||
// CONSOLE
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
scroll_id: $scroll_id1
|
||||
|
||||
---
|
||||
"Body params override query string":
|
||||
"Body params with array param override query string":
|
||||
- do:
|
||||
indices.create:
|
||||
index: test_scroll
|
||||
|
@ -76,3 +76,47 @@
|
|||
catch: missing
|
||||
clear_scroll:
|
||||
scroll_id: $scroll_id1
|
||||
|
||||
---
|
||||
"Body params with string param scroll id override query string":
|
||||
- skip:
|
||||
version: " - 5.99.99"
|
||||
reason: this uses a new API that has been added in 6.0
|
||||
|
||||
- do:
|
||||
indices.create:
|
||||
index: test_scroll
|
||||
- do:
|
||||
index:
|
||||
index: test_scroll
|
||||
type: test
|
||||
id: 42
|
||||
body: { foo: bar }
|
||||
|
||||
- do:
|
||||
indices.refresh: {}
|
||||
|
||||
- do:
|
||||
search:
|
||||
index: test_scroll
|
||||
scroll: 1m
|
||||
body:
|
||||
query:
|
||||
match_all: {}
|
||||
|
||||
- set: {_scroll_id: scroll_id1}
|
||||
|
||||
- do:
|
||||
clear_scroll:
|
||||
scroll_id: "invalid_scroll_id"
|
||||
body: { "scroll_id": "$scroll_id1" }
|
||||
|
||||
- do:
|
||||
catch: missing
|
||||
scroll:
|
||||
scroll_id: $scroll_id1
|
||||
|
||||
- do:
|
||||
catch: missing
|
||||
clear_scroll:
|
||||
scroll_id: $scroll_id1
|
||||
|
|
Loading…
Reference in New Issue