# One shot search query by scroll from index \> 10'000

**URL:** <https://discuss.elastic.co/t/one-shot-search-query-by-scroll-from-index-10000/224396>\
**Category:** Elasticsearch\
**Created:** [March 20, 2020, 10:07am UTC](https://discuss.elastic.co/t/one-shot-search-query-by-scroll-from-index-10000/224396 "2020-03-20T10:07:34Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![missill](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/missill/32/64813_2.png) [@missill](https://discuss.elastic.co/u/missill)\
**Post date:** [March 20, 2020, 10:07am UTC](https://discuss.elastic.co/t/one-shot-search-query-by-scroll-from-index-10000/224396/1 "2020-03-20T10:07:34Z")

</div>

Hi everybody,

I'd like get result from a search query from start index \> 10000 but when i do it, i get this error :

```auto
{"error":{"root_cause":[{"type":"query_phase_execution_exception","reason":"Result window is too large, from + size must be less than or equal to: [10000] but was [50000]. See the scroll api for a more efficient way to request large data sets. This limit can be set by changing the [index.max_result_window] index level setting."}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"logs","node":"4ADMH6H9SeWAwb0M9ehCsg","reason":{"type":"query_phase_execution_exception","reason":"Result window is too large, from + size must be less than or equal to: [10000] but was [12020]. See the scroll api for a more efficient way to request large data sets. This limit can be set by changing the [index.max_result_window] index level setting."}}]},"status":500}

```

I don't want paginate so I'm scared to well understand that i should do a scroll search query and loop with scroll\_id until i arrive to the index i'm searching ?

What's the good process to do it ?

Thanks for any response.

---

<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:** [March 20, 2020, 10:43am UTC](https://discuss.elastic.co/t/one-shot-search-query-by-scroll-from-index-10000/224396/2 "2020-03-20T10:43:11Z")

</div>

Welcome!

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.

---

<div class="post-metadata">

**Author:** ![missill](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/missill/32/64813_2.png) [@missill](https://discuss.elastic.co/u/missill)\
**Post date:** [March 20, 2020, 3:40pm UTC](https://discuss.elastic.co/t/one-shot-search-query-by-scroll-from-index-10000/224396/3 "2020-03-20T15:40:58Z")

</div>

Hi dadoonet,

Thanks for your time and response.  
I find it so weird but i used scroll api and custom script to achieve my goals.  
If i want the 10 first results from 1'000'000th result, i'll use Scroll API and loop  
100 times. It seems so heavy and not optimized.  
I am certainly going somewhere wrong.

Best regards.

---

<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:** [March 20, 2020, 4:09pm UTC](https://discuss.elastic.co/t/one-shot-search-query-by-scroll-from-index-10000/224396/5 "2020-03-20T16:09:39Z")

</div>

Yes. If you want to have access to the 1,000,000 to 1,000,010 hits, you will probably need to do what you described.

But you did not tell what is the use case. Could you explain?

---

<div class="post-metadata">

**Author:** ![missill](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/missill/32/64813_2.png) [@missill](https://discuss.elastic.co/u/missill)\
**Post date:** [March 23, 2020, 1:37pm UTC](https://discuss.elastic.co/t/one-shot-search-query-by-scroll-from-index-10000/224396/6 "2020-03-23T13:37:18Z")

</div>

For pagination example,  
Imagine we wants to display 1000 hits per page and we have 1 000 000 records,  
We ll have 1000 pages. So if you want to get the last page, we loop 1000 times before obtain wanted 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:** [March 23, 2020, 2:03pm UTC](https://discuss.elastic.co/t/one-shot-search-query-by-scroll-from-index-10000/224396/7 "2020-03-23T14:03:48Z")

</div>

But does it make sense for a end user to navigate to page 10000? Or 100000?

I mean: how many times are you going to page 10 on google?

---

<div class="post-metadata">

**Author:** ![missill](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/missill/32/64813_2.png) [@missill](https://discuss.elastic.co/u/missill)\
**Post date:** [March 23, 2020, 5:02pm UTC](https://discuss.elastic.co/t/one-shot-search-query-by-scroll-from-index-10000/224396/8 "2020-03-23T17:02:01Z")

</div>

You're right.  
Thanks Dadoo,  
Cheers.

---

<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:** [April 21, 2020, 4:34pm UTC](https://discuss.elastic.co/t/one-shot-search-query-by-scroll-from-index-10000/224396/10 "2020-04-21T16:34:02Z")

</div>

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