ElasticSearch pagination - from/size vs Search After for number of hits less than 10k

Hi,

I'm using Elasticsearch, and for paginating the search results, should I use the simple from/size, or should I go with search after. I've read that if the number of hits is less than 10k, then from/size is acceptable. Even though my total search space is much more than 10k, but the number of hits/matches I'm expecting is around 5k at max.

For this, would there be a lot of performance difference between from/size and search after? I'm leaning towards from/size since search after is relatively trickier to implement, specially when there's a requirement for going back to a previous page.

Thanks!

Hi!

I don't know if you read the posts below, but maybe I can help you.

Article Opster
Question Stackoverflow

Hi,
Thank you for your response, and the helpful links!
But is there some threshold/recommendation as to what would be the maximum size of the result set on which from/size and search after would perform roughly the same?

I understand that it will also depend on other factors, like query logic, or size of the analysed data we're querying on(The size of 1 document for us is about 5-10kb).

We're building a e-commerce type search from scratch, and I don't expect the search results of a query to be more than 500, or 1k.
It's difficult to to do a POC on both approaches, since we don't have data in that scale yet, and I'm leaning towards from/size. Hence, was looking for some empirical data/advice from people with more experience on this.

It seems that one of the requirements is to have access to the previous page, in which case I would also use from/size respecting the restrictions of this implementation.

1 Like

Thanks a lot!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.