Google answered my question, and indeed I was missing something obvious. For others who are wondering here is a very clear example (something like this could make the ES docs a little more clear):
- If there are 31 annotations—1 for each day in October—the search parameter combination of
sort=updated,order=desc,limit=10, andsearch_after=2018-10-05 will retrieve annotations made from the 6th of October to the 16th of October. - If there are 31 annotations with IDs 0-31, the search parameter combination of
sort=id,order=asc,limit=10, andsearch_after=5, will return the annotations with IDs 6-16.
Searching using offset and limit is inefficient because elasticsearch must load all the annotations ( offset + limit number of annotations) into memory and sort them before returning the window of annotations defined by offset and limit . search_after does not require all the annotations to be loaded and sorted because it can be applied as a filter on the search query itself—as opposed to offset , which must be applied after the initial search. This is why search_after is more efficient and, while the old parameter offset does remain, it is not recommended to use it.