# Clear scroll with slices

**URL:** https://discuss.elastic.co/t/clear-scroll-with-slices/169826
**Category:** Elasticsearch
**Created:** [February 25, 2019, 12:13pm UTC](https://discuss.elastic.co/t/clear-scroll-with-slices/169826 "2019-02-25T12:13:15Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![zoraida](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zoraida/32/41293_2.png) [@zoraida](https://discuss.elastic.co/u/zoraida)
#### Post date: [February 25, 2019, 12:13pm UTC](https://discuss.elastic.co/t/clear-scroll-with-slices/169826/1 "2019-02-25T12:13:15Z")

</div>

Hi all,

I am trying to use the Scroll Rest API and I had a doubt that was resolved here:

> [@Clear scroll clarification](https://discuss.elastic.co/t/clear-scroll-clarification/76596):
>
> Hi all, Question about scroll and clear scroll: Ref: [https://www.elastic.co/guide/en/elasticsearch/reference/2.4/search-request-scroll.html](https://www.elastic.co/guide/en/elasticsearch/reference/2.4/search-request-scroll.html) The documentation says that The initial search request and each subsequent scroll request returns a new \_scroll\_id — only the most recent \_scroll\_id should be used. and scrolls should be explicitly cleared as soon as the scroll is not being used anymore My question is Does it mean that each loop can clear the previous scrollId, or do w…

However, when using slices, what does the last scroll\_id mean? I have play around with the API and I saw that, by calling the Clear Scroll API with any id among all the scrolls in the same context(or search) the result is the same: search invalidation and not longer results can be retrieved. Then, it is mandatory to use "the last scroll id" or can be used any of them? (for instance the first returned by the initial search request)

Thanks,

Z.-

---

<div class="post-metadata">

### Author: ![xavierfacq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xavierfacq/32/8744_2.png) [@xavierfacq](https://discuss.elastic.co/u/xavierfacq)
#### Post date: [February 28, 2019, 1:19pm UTC](https://discuss.elastic.co/t/clear-scroll-with-slices/169826/2 "2019-02-28T13:19:37Z")

</div>

Hi,

I use the last given scroll Id passed to the next scroll request. And, at the end of all scroll, I delete the last given scroll id.

> The initial search request and each subsequent scroll request each return a `_scroll_id` . While the `_scroll_id` may change between requests, it doesn’t always change — in any case, only the most recently received `_scroll_id` should be used.

bye,  
Xavier

---

<div class="post-metadata">

### Author: ![zoraida](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zoraida/32/41293_2.png) [@zoraida](https://discuss.elastic.co/u/zoraida)
#### Post date: [February 28, 2019, 1:44pm UTC](https://discuss.elastic.co/t/clear-scroll-with-slices/169826/3 "2019-02-28T13:44:57Z")

</div>

Hi Xavi,

I understood your strategy, thanks a lot. The point is that I did some testing and I realized that, by using any of the scroll\_id's was enough, I mean, the context search was cleared. It would be "nicer" for me to use the first scroll\_id(just because I am using some stream library that fits better with this approach). That is why I am asking, just to confirm.

Thanks!

Z.-

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [March 28, 2019, 1:45pm UTC](https://discuss.elastic.co/t/clear-scroll-with-slices/169826/4 "2019-03-28T13:45:03Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
