# Maximums for searchAfter (and scroll) size parameter?

**URL:** <https://discuss.elastic.co/t/maximums-for-searchafter-and-scroll-size-parameter/273591>\
**Category:** Elasticsearch\
**Created:** [May 20, 2021, 10:42pm UTC](https://discuss.elastic.co/t/maximums-for-searchafter-and-scroll-size-parameter/273591 "2021-05-20T22:42:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![elastic\_yogi](https://avatars.discourse-cdn.com/v4/letter/e/71c47a/32.png) [@elastic\_yogi](https://discuss.elastic.co/u/elastic_yogi)\
**Post date:** [May 20, 2021, 10:42pm UTC](https://discuss.elastic.co/t/maximums-for-searchafter-and-scroll-size-parameter/273591/1 "2021-05-20T22:42:48Z")

</div>

Hi, I'm curious about ES 7.12 `searchAfter` and `scroll`. Both of these have a `size` parameter. What's the recommended limit to this parameter? I see none given, so I take it's a function of memory and cluster capacity somehow? Both `searchAfter` and `scroll` are also not affected by the `index.max_result_window` in any way, correct? Thank you.

---

<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:** [May 21, 2021, 4:50am UTC](https://discuss.elastic.co/t/maximums-for-searchafter-and-scroll-size-parameter/273591/2 "2021-05-21T04:50:11Z")

</div>

I believe that the limit is the same, 100000 by default.

---

<div class="post-metadata">

**Author:** ![elastic\_yogi](https://avatars.discourse-cdn.com/v4/letter/e/71c47a/32.png) [@elastic\_yogi](https://discuss.elastic.co/u/elastic_yogi)\
**Post date:** [May 21, 2021, 4:47pm UTC](https://discuss.elastic.co/t/maximums-for-searchafter-and-scroll-size-parameter/273591/3 "2021-05-21T16:47:43Z")

</div>

@dadoonet Thanks. So 10k. Wish this was stated in the documentation.

I'm curious if it's the same because `scroll` and `searchAfter` basically chunk a much larger request into multiple requests in a way (e.g. pointers) that use less heap memory than `from` + `size`? That's my interpretation of the documentation below:

`index.max_result_window`:

> The maximum value of `from + size` for searches to this index. Defaults to `10000` . Search requests take heap memory and time proportional to `from + size` and this limits that memory. See [Scroll](https://www.elastic.co/guide/en/elasticsearch/reference/current/paginate-search-results.html#scroll-search-results) or [Search After](https://www.elastic.co/guide/en/elasticsearch/reference/current/paginate-search-results.html#search-after) for a more efficient alternative to raising this.

---

<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:** [May 21, 2021, 5:23pm UTC](https://discuss.elastic.co/t/maximums-for-searchafter-and-scroll-size-parameter/273591/4 "2021-05-21T17:23:24Z")

</div>

That will produce the same. You can't more than 10000 hits at once whatever the API.

Scroll helps to get the next 10000 hits while being consistent.

---

<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:** [June 18, 2021, 5:24pm UTC](https://discuss.elastic.co/t/maximums-for-searchafter-and-scroll-size-parameter/273591/5 "2021-06-18T17:24:14Z")

</div>

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