Use the SearchAfter feature for paginated queries on Elasticsearch
Description
Activity
Yoann Rodière March 20, 2024 at 8:33 AM
To implement this feature, we would ideally need a way to convert field values to and from a string, so that users can take “sort values” from a query, and serialize/deserialize them as necessary in the frontend.
Note that the beginning of what we’d need was implemented as part of HSEARCH-5109: Introduce `ValueConvert.PARSE` to provide built-in converters for string valuesClosed : we now have the ability, for a given field, to parse a string to a value of the field type. We’d just need the opposite operation (formatting to string) and we’d be all set.
Yoann Rodière March 20, 2024 at 8:29 AM
Interestingly, a similar feature has been added to ORM 6.5 with org.hibernate.query.SelectionQuery#getKeyedResultList
. We might want to integrate with it in HibernateOrmSearchQueryAdapter
if possible (but I suspect the feature’s reliance on the JPA metamodel will prevent us from doing so).
See Paginate search results | Elasticsearch Guide [8.17] | Elastic