If all scroll ids should be removed then the `_all` value should be used instead of not specifying any scroll ids.
This commit is contained in:
parent
1fe72dcf56
commit
8ddb809f98
|
@ -142,5 +142,10 @@ resources to keep the view open will cleaned open. Example usage:
|
|||
curl -XDELETE 'localhost:9200/_search/scroll/c2NhbjsxOjBLMzdpWEtqU2IyZHlmVURPeFJOZnc7MzowSzM3aVhLalNiMmR5ZlVET3hSTmZ3OzU6MEszN2lYS2pTYjJkeWZVRE94Uk5mdzsyOjBLMzdpWEtqU2IyZHlmVURPeFJOZnc7NDowSzM3aVhLalNiMmR5ZlVET3hSTmZ3Ow=='
|
||||
--------------------------------------------------
|
||||
|
||||
Multiple scroll ids can be specified in a comma separated manner, if no id is
|
||||
specified then all scroll ids will be cleared up.
|
||||
Multiple scroll ids can be specified in a comma separated manner.
|
||||
If all scroll ids need to be cleared the reserved `_all` value can used instead of an actual `scroll_id`:
|
||||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
curl -XDELETE 'localhost:9200/_search/scroll/_all'
|
||||
--------------------------------------------------
|
|
@ -29,6 +29,7 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
import static org.elasticsearch.action.ValidateActions.addValidationError;
|
||||
|
||||
/**
|
||||
*/
|
||||
|
@ -53,7 +54,11 @@ public class ClearScrollRequest extends ActionRequest {
|
|||
|
||||
@Override
|
||||
public ActionRequestValidationException validate() {
|
||||
return null;
|
||||
ActionRequestValidationException validationException = null;
|
||||
if (scrollIds == null || scrollIds.isEmpty()) {
|
||||
validationException = addValidationError("no scroll ids specified", validationException);
|
||||
}
|
||||
return validationException;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -69,7 +69,7 @@ public class TransportClearScrollAction extends TransportAction<ClearScrollReque
|
|||
private Async(ClearScrollRequest request, ActionListener<ClearScrollResponse> listener, ClusterState clusterState) {
|
||||
int expectedOps = 0;
|
||||
this.nodes = clusterState.nodes();
|
||||
if (request.getScrollIds() == null || request.getScrollIds().isEmpty()) {
|
||||
if (request.getScrollIds().size() == 1 && "_all".equals(request.getScrollIds().get(0))) {
|
||||
expectedOps = nodes.size();
|
||||
} else {
|
||||
for (String parsedScrollId : request.getScrollIds()) {
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
package org.elasticsearch.search.scroll;
|
||||
|
||||
import org.elasticsearch.AbstractSharedClusterTest;
|
||||
import org.elasticsearch.action.search.ClearScrollResponse;
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.action.search.SearchType;
|
||||
|
@ -27,7 +28,6 @@ import org.elasticsearch.common.settings.ImmutableSettings;
|
|||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.search.SearchHit;
|
||||
import org.elasticsearch.search.sort.SortOrder;
|
||||
import org.elasticsearch.AbstractSharedClusterTest;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Map;
|
||||
|
@ -367,7 +367,7 @@ public class SearchScrollTests extends AbstractSharedClusterTest {
|
|||
assertThat(((Number) hit.sortValues()[0]).longValue(), equalTo(counter2++));
|
||||
}
|
||||
|
||||
ClearScrollResponse clearResponse = client().prepareClearScroll()
|
||||
ClearScrollResponse clearResponse = client().prepareClearScroll().addScrollId("_all")
|
||||
.execute().actionGet();
|
||||
assertThat(clearResponse.isSucceeded(), equalTo(true));
|
||||
|
||||
|
|
Loading…
Reference in New Issue