# How to scroll back in Elasticsearch Search Scroll API

**URL:** https://discuss.elastic.co/t/how-to-scroll-back-in-elasticsearch-search-scroll-api/227149
**Category:** Elasticsearch
**Created:** [April 8, 2020, 2:18pm UTC](https://discuss.elastic.co/t/how-to-scroll-back-in-elasticsearch-search-scroll-api/227149 "2020-04-08T14:18:49Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Amine\_Maalfi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/amine_maalfi/32/62335_2.png) [@Amine\_Maalfi](https://discuss.elastic.co/u/Amine_Maalfi)
#### Post date: [April 8, 2020, 2:18pm UTC](https://discuss.elastic.co/t/how-to-scroll-back-in-elasticsearch-search-scroll-api/227149/1 "2020-04-08T14:18:50Z")

</div>

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

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [April 9, 2020, 1:02am UTC](https://discuss.elastic.co/t/how-to-scroll-back-in-elasticsearch-search-scroll-api/227149/2 "2020-04-09T01:02:38Z")

</div>

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

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

---

<div class="post-metadata">

### Author: ![Amine\_Maalfi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/amine_maalfi/32/62335_2.png) [@Amine\_Maalfi](https://discuss.elastic.co/u/Amine_Maalfi)
#### Post date: [April 9, 2020, 1:21am UTC](https://discuss.elastic.co/t/how-to-scroll-back-in-elasticsearch-search-scroll-api/227149/3 "2020-04-09T01:21:04Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [April 9, 2020, 1:40am UTC](https://discuss.elastic.co/t/how-to-scroll-back-in-elasticsearch-search-scroll-api/227149/4 "2020-04-09T01:40:46Z")

</div>

You can use:

- the [`size` and `from` parameters](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-from-size.html) 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](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-search-after.html) feature to do deep pagination.
- the [Scroll API](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html) 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?

---

<div class="post-metadata">

### Author: ![Amine\_Maalfi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/amine_maalfi/32/62335_2.png) [@Amine\_Maalfi](https://discuss.elastic.co/u/Amine_Maalfi)
#### Post date: [April 9, 2020, 1:45am UTC](https://discuss.elastic.co/t/how-to-scroll-back-in-elasticsearch-search-scroll-api/227149/5 "2020-04-09T01:45:26Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [April 9, 2020, 3:50am UTC](https://discuss.elastic.co/t/how-to-scroll-back-in-elasticsearch-search-scroll-api/227149/6 "2020-04-09T03:50:51Z")

</div>

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.

---

<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: [May 7, 2020, 3:51am UTC](https://discuss.elastic.co/t/how-to-scroll-back-in-elasticsearch-search-scroll-api/227149/7 "2020-05-07T03:51:01Z")

</div>

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