# Backward pagination with search\_after and PIT

**URL:** <https://discuss.elastic.co/t/backward-pagination-with-search-after-and-pit/371981>\
**Category:** Elasticsearch\
**Created:** [December 14, 2024, 11:17am UTC](https://discuss.elastic.co/t/backward-pagination-with-search-after-and-pit/371981 "2024-12-14T11:17:31Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sandra\_a](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sandra_a/32/126560_2.png) [@sandra\_a](https://discuss.elastic.co/u/sandra_a)\
**Post date:** [December 14, 2024, 11:17am UTC](https://discuss.elastic.co/t/backward-pagination-with-search-after-and-pit/371981/1 "2024-12-14T11:17:32Z")

</div>

Hello;  
I used From and Size for pagination, but it doesn't retrieve more than 10,000 docs. I read Document about pagination and saw search\_after and PIT.  
I have a question about this.  
what if i want to see previous pages with these variables???

---

<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:** [December 14, 2024, 12:21pm UTC](https://discuss.elastic.co/t/backward-pagination-with-search-after-and-pit/371981/2 "2024-12-14T12:21:55Z")

</div>

What is the use case for this?

Do you have a user who wants to go to page 9716 and then want to see a hit on page 9715?

---

<div class="post-metadata">

**Author:** ![sandra\_a](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sandra_a/32/126560_2.png) [@sandra\_a](https://discuss.elastic.co/u/sandra_a)\
**Post date:** [December 14, 2024, 1:20pm UTC](https://discuss.elastic.co/t/backward-pagination-with-search-after-and-pit/371981/3 "2024-12-14T13:20:30Z")

</div>

@dadoonet

like a web application to see docs.  
Yes For example it is a movie list.

---

<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:** [December 14, 2024, 2:16pm UTC](https://discuss.elastic.co/t/backward-pagination-with-search-after-and-pit/371981/4 "2024-12-14T14:16:16Z")

</div>

Right. How often are going to page 9716 when searching for movies on Google for example?

I believe that you are expecting to have on the first page the content you are looking for, right?

That's the point of using a search engine. Relevancy.

If you don't see what you are looking for on the first 10 pages, I think you should refine your search or sort by another field or add faceted navigation to filter easily the resultset.

---

<div class="post-metadata">

**Author:** ![sandra\_a](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sandra_a/32/126560_2.png) [@sandra\_a](https://discuss.elastic.co/u/sandra_a)\
**Post date:** [December 15, 2024, 5:39am UTC](https://discuss.elastic.co/t/backward-pagination-with-search-after-and-pit/371981/5 "2024-12-15T05:39:52Z")

</div>

@dadoonet

Yes I'm agree with that. But it sometimes could be happen. I think the best way is designing page with infinite load more.

---

<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:** [December 15, 2024, 6:29am UTC](https://discuss.elastic.co/t/backward-pagination-with-search-after-and-pit/371981/6 "2024-12-15T06:29:20Z")

</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/paginate-search-results.html#search-after) feature to do deep pagination.
- the [Scroll API](https://www.elastic.co/guide/en/elasticsearch/reference/current/paginate-search-results.html#scroll-search-results) if you want to extract a resultset to be consumed by another tool later. (Not recommended anymore)
