I'm trying to find a way to combine pagination and search over a resultset of an aggregation.
I have a sorted aggregation that returns 20 buckets per page (I'm doing it with composite aggregation and after attribute, but I've tryed truncating with bucket_sort too).
Now I want to search by bucket key and get as result the searched bucket and the next 19 buckets. The tricky part is that I need (or I think I need) the position of the searched bucket within the sortd aggregation to update the pagination info (something like "showing from xx to [xx+20] of [total]", and enable or disable the navigations buttons).
I think the problem could be solved knowing the position of each bucket when sorted by some field, but I can't find anywhere if this is possible.
Any idea on how to solve it?