Skip to content

Commit

Permalink
The clear scroll apis now optionally accepts a scroll_id in it body.
Browse files Browse the repository at this point in the history
Closes #5726
  • Loading branch information
martijnvg committed Apr 11, 2014
1 parent a786db6 commit 25eed49
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
4 changes: 3 additions & 1 deletion rest-api-spec/api/clear_scroll.json
Expand Up @@ -14,6 +14,8 @@
},
"params": {}
},
"body": null
"body": {
"description": "A comma-separated list of scroll IDs to clear if none was specified via the scroll_id parameter"
}
}
}
34 changes: 34 additions & 0 deletions rest-api-spec/test/scroll/11_clear.yaml
@@ -0,0 +1,34 @@
---
"Clear scroll":
- 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
search_type: scan
scroll: 1m
body:
query:
match_all: {}

- set: {_scroll_id: scroll_id1}

- do:
clear_scroll:
scroll_id: $scroll_id1

- do:
catch: request
scroll:
scroll_id: $scroll_id1
Expand Up @@ -27,8 +27,8 @@
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentBuilderString;
import org.elasticsearch.rest.*;
import org.elasticsearch.rest.action.support.RestActions;

import java.io.IOException;
import java.util.Arrays;
Expand All @@ -52,6 +52,9 @@ public RestClearScrollAction(Settings settings, Client client, RestController co
@Override
public void handleRequest(final RestRequest request, final RestChannel channel) {
String scrollIds = request.param("scroll_id");
if (scrollIds == null) {
scrollIds = RestActions.getRestContent(request).toUtf8();
}

ClearScrollRequest clearRequest = new ClearScrollRequest();
clearRequest.setScrollIds(Arrays.asList(splitScrollIds(scrollIds)));
Expand Down

0 comments on commit 25eed49

Please sign in to comment.