I've built my API on Elasticsearch such that users can specify their
filters and retrieve data accordingly. For example, a user can specify
"return all products of brand Samsung" and I internally run something along
the lines of:
'{"query" : {"filtered" : {"query" : {"match_all" : {}}, "filter" :
{"term" : {"brand" : "Samsung"}}}}, "size" : 10, "from" : 50}'
Each API call returns 10 results at a time. However, I want the user to be
able to paginate through the responses if it interests him/her. Hence, I
also allow the user to specify the "from" field.
So my question is this: can I guarantee genuine pagination if the user only
changes the "from" field in successive queries? By "genuine" pagination, I
mean, can I be sure that successive pages won't contain the same document?
Note:
- I'm not using any scroll/scan features.
- API queries may be made several days apart, so caching is not guaranteed.
- I'm not using any "sort" fields so as to save on memory used.
- Queries may contain only "query" fields, only "filter" fields, or both.
Hence scoring may or may not play a role.
--