Accessing end of dataset with search_after

Hello,

We are using search_after to populate and paginate a data grid using fetch requests from an index with around 200,000 documents. We would like to include a "jump to last page" button in our table, but search_after does not give access to random data fetching. I am not sure how/if there is a way to access the last block of data to populate the last page of our data table.

The data itself does not change but I need to make new requests depending on sorting parameters. The last block/page always comes after the nth document since the size of the data doesn't change between sorts, but I don't have a way to know what the nth document is, to fetch the block starting at n + 1.

Using what scarce resources there are online, the only solution I've found is to build a "pagination_index", ie an list of the search_after values (referencing last document in a block) for each block. If I want to access the nth block, then I will use pagination_index[n-1] as the search after value. Building this pagination_index will require fetching all the blocks of data, taking the last document's sort value, and constructing an array, which takes time and resources. Are there any other solutions to this problem?

Thanks for any help and let me know if any part is unclear

There is no feature in Elasticsearch to access any pages of the search results. It is explicitly explained in the point in time API page. If you need only the last page, one trick could be get the first page of up-side-down order.

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