Skip to main content
InterviewHubPRO
Section Overview
Q16

Question 16 of 50

Part 2: Core Architecture & Implementation (Mid-Level)

32%
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:

  1. from + size: Traditional offset pagination. Limited by index.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.
  2. search_after (Recommended): Cursor-based pagination using the sort values of the last document. Operates with constant memory and time complexity O(1).
  3. scroll API: Creates a point-in-time snapshot for streaming massive datasets (e.g. reindexing millions of records). Not designed for real-time user requests.