Using Elasticsearch scroll api for every request using rest api

Hi All,

I have a scenario for using Elasticsearch Scroll API. Please find the below details,

  1. I have implemented ES scroll api in our application.
  2. I am able to get the unique records for each request using rest api by scroll id
  3. But unable to close the scroll id's
  4. If I close the scroll Id, next request using the scroll id is failing

Please let me know, when and how to close the scroll id's.


Why do you want to close it before you're done scrolling the full data?

So, do you mean like, its not required to close the scrolls.
Could you please explain me.

You can close the scroll once you're done reading all the data you needed.

1 Like

Thank you for that information.
But As I mentioned in my previous post, currently our requirement is like, request based scrolling should happen which means, from user we will be getting the Scroll Id in our request.
So, I meant here is, basically scrolling happens at a stretch in our code in a loop, once cursor comes out of the loop, we will close the scrolls.
But in our requirement, we can't do like that, its a kind of scroll based pagination.
So, please let me know is it required to close them.
Also could you please tell me whether can we go to previous scroll page results by using old scrollId.


No scroll is always forward. You can't go backward.

May be you should use that instead?

1 Like

Thank you very much for your suggestion.
One last query reg search-after, can we do random pagination using this search-after implementation.


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