What is the Scroll API and when should you use it?
Answer
The Scroll API is designed for retrieving large numbers of results (thousands to millions) from Elasticsearch in batches, without the limitations of regular pagination. A regular search with from + size pagination becomes prohibitively expensive beyond from: 10000 because Elasticsearch must rank all matching documents up to that offset. With the Scroll API, the first request creates a "scroll context" (a snapshot of the search state) and returns a _scroll_id. Subsequent requests use this ID to retrieve the next batch. Use Scroll for bulk exports and data migration. For live, paginated UIs, use search_after instead — Scroll contexts consume significant heap memory.
Previous
What is an index alias in Elasticsearch?
Next
What is search_after pagination in Elasticsearch?
More Elasticsearch Questions
View all →- Intermediate What is the difference between query context and filter context in Elasticsearch?
- Intermediate What is a bool query in Elasticsearch?
- Intermediate What are aggregations in Elasticsearch?
- Intermediate What is the difference between text and keyword field types?
- Intermediate What are index templates and component templates in Elasticsearch?