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

Hi everybody,

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

{"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.

Welcome!

You can use:

  • the size and from parameters 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 feature to do deep pagination.
  • the Scroll API if you want to extract a resultset to be consumed by another tool later.

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.

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?

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.

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?

You're right.
Thanks Dadoo,
Cheers.