🔍 Elasticsearch
Intermediate
What is search_after pagination in Elasticsearch?
Answer
search_after is the recommended pagination method for deep pagination in live search UIs. Unlike from + size which becomes expensive for deep pages, search_after uses the sort values of the last document on the current page as a cursor for the next page. You must include a sort clause with a unique tiebreaker field (like _id). The next page request passes the last document's sort values in the search_after array. This approach is stateless (no scroll context to maintain) and performs consistently regardless of how deep the page is. It is ideal for infinite scroll UIs and cursor-based pagination APIs.
Previous
What is the Scroll API and when should you use it?
Next
What is the Highlight API 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?