Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Max scrollable time for elasticsearch

What is the max scrollable time that can be set for scrolling search ?

Documentation: https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference.html#api-scroll

like image 359
Hexy Avatar asked Jul 24 '26 18:07

Hexy


1 Answers

If you're asking this kind of question you're probably not using Scroll in ES how it was intended. You want to use scroll when you know for sure that you need to return ALL matching records.

Great use case for Scroll

I want to pull back 1,000,000 records from ES to be written to a CSV file. This is a perfect use case for scroll. You need to return 1M rows, but you don't want to return them all as 1 chunk from the database. Instead you can chunk them into ~1000 record chunks, write the chunk to the CSV file, then get the next chunk. Your scroll keep alive can be set to 1 minute and you'll have no problems.

Bad use case for Scroll

A user is viewing the first 50 records and at some time in the future, they may or may not want to view the next 50 records.

For a use case like this you want to use the Search After API

like image 87
jhilden Avatar answered Jul 26 '26 12:07

jhilden