I want to implement pagination using search_after instead of from, size. There are different sortings in our website like sort by relevancy or a-z or z-a or lowest to highest… How will the sort values for search_after considered in this cases. What will be the changes required on the UI side. Can I use next and previous buttons or only load more button?
Which one is ideal for a e-commerce B2B website, search_after or from size?
With search_after you can't go back to the previous page. If you need to do that, you will have to store in your app layer, the hits you have already downloaded or each search_after array result to provide it again to the search request.
There's no real change with the sort capabilities so that should not have an impact on the UI.
Out of curiosity, why do you want to make this change?
There was a recommendation : Pagination is currently performed by applying `from` and `size` parameters to the search. This is inefficient as the entire query is run for every page. A more efficient alternative is to use `search_after`, which enables Elasticsearch to only read the documents that are required for the page being requested.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.