# Why is search\_after preferred over Scroll API?

**URL:** <https://discuss.elastic.co/t/why-is-search-after-preferred-over-scroll-api/292989>\
**Category:** Elasticsearch\
**Created:** [December 27, 2021, 3:07pm UTC](https://discuss.elastic.co/t/why-is-search-after-preferred-over-scroll-api/292989 "2021-12-27T15:07:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dandago](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dandago/32/56215_2.png) [@dandago](https://discuss.elastic.co/u/dandago)\
**Post date:** [December 27, 2021, 3:07pm UTC](https://discuss.elastic.co/t/why-is-search-after-preferred-over-scroll-api/292989/1 "2021-12-27T15:07:29Z")

</div>

I've read that "We no longer recommend using the scroll API for deep pagination. If you need to preserve the index state while paging through more than 10,000 hits, use the [`search_after`](https://www.elastic.co/guide/en/elasticsearch/reference/current/paginate-search-results.html#search-after) parameter with a point in time (PIT)." (source: [Paginate search results | Elasticsearch Guide [7.16] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/paginate-search-results.html) )

However, I haven't been able to find any explanation WHY search\_after is preferred and Scroll API is being cast aside. As far as I can tell, using search\_after with PIT would require Elasticsearch to keep data around for the duration of the time window just like with Scroll API. Also, I've run a basic test comparing the two approaches, and it appears that search\_after is actually slower and scales worse.

---

<div class="post-metadata">

**Author:** ![Johnnycc1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/johnnycc1/32/26069_2.png) [@Johnnycc1](https://discuss.elastic.co/u/Johnnycc1)\
**Post date:** [December 28, 2021, 11:13am UTC](https://discuss.elastic.co/t/why-is-search-after-preferred-over-scroll-api/292989/2 "2021-12-28T11:13:26Z")

</div>

Afternoon Daniel, I'm also interested as to why scroll is not being recommended going forward. And we are suggested to use search\_after with a PIT - if we want to extract the data at the point in time of the first query.

I'm also interested to hear if the "scan" function within the Elasticsearch python client, which still uses scroll, is intended to be replaced with search after and a PIT.

---

<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:** [January 25, 2022, 11:13am UTC](https://discuss.elastic.co/t/why-is-search-after-preferred-over-scroll-api/292989/3 "2022-01-25T11:13:31Z")

</div>

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