How to scroll back in Elasticsearch Search Scroll API

Hello everyone is there a way to scroll up and down in the search scroll API of Elasticsearch? i mean, if i reach the end and nothing shows i want to go back in the opposite direction.
if it's not possible is there a workaround for it.
Thanks in advance

A scroll is one way, forward. You cannot go back.

If nothing shows then what do you have to scroll back on though?

the reason why is simple! i have a datatable in an angular app with pagination where i want to show only 100 hits of the result, and i want two buttons to show next and previous results.

You can use:

  • the size and from parameters to display by default up to 10000 records to your users. If you want to change this limit, you can change index.max_result_window setting but be aware of the consequences (ie memory).
  • the search after feature to do deep pagination.
  • the Scroll API if you want to extract a resultset to be consumed by another tool later.

In the future scroll will probably replaced by another feature (search after) which will allow to have a frozen view of the index in which you can navigate backward and forward. But it's not yet there.

How many total records (or pages) do you want your user to be able to navigate?

1 Like

sometimes it may go up to 100.000 records since it's log data, i think i'll use the scroll API and push the data to an array after each scroll.
Thank you for your response you showed me more possibilities i didn't know about.

IMHO as a user, I'd never go to page 999 to see the last records.
I would most likely add more things in the search bar or I'd reverse the sort to see the oldest logs first but I'd certainly not navigate through 10000 pages.

1 Like

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