Elasticsearch & Lucene (50 Qs)•Part 2: Core Architecture & Implementation (Mid-Level)
What are the pagination methods in Elasticsearch: from/size vs search_after vs scroll?
senior LevelSystem Design
In Simple Words:
from+size: Traditional offset pagination. Limited byindex.max_result_window(default 10,000). Fetching page 1,000 (offset 100,000) forces every shard to build and sort 100,000 documents in memory, causing OOM.search_after(Recommended): Cursor-based pagination using the sort values of the last document. Operates with constant memory and time complexity O(1).scrollAPI: Creates a point-in-time snapshot for streaming massive datasets (e.g. reindexing millions of records). Not designed for real-time user requests.