Using search_after. Getting skipped count and rest count

Hi, everyone!

I have an index of documents which search using sorting and search_after parameter. Every page is an outer request. I need to know, how many documents is skipped for the current value of search_after parameter and how many document is rest to the end.

Which way I could do this?

I do not see a way of doing this currently. Also, it does not make sense to keep track of this in the client, as those numbers can change due to concurrent indexing/deletions.

May I ask what the use-case is? Maybe there is another way of achieving what you need.

I'll try to explain. There are two scenarios.

The first scenario

I have a paged list of documents sorted by date (for our purposes). Actually this is web page. This page contains:

  • total documents count (might approximately, for example, 250 or 1000+)
  • current page number
  • next page link (if there are documents)
  • prev page link (if page is not first or, equivalently, skipped count large than 0)
    The next/prev links contain encoded after_search parameter. For the next link (call it as afterKey) is a sort-set of the last document of list. For the prev link (call it as beforeKey) is a sort-set of the first document of list.
    Here we need to know current page number, that is skipped count. Yes, count of documents can change but it is OK.

The second scenario

I have API. It has a method for filtering of documents. It also support cursor (actually, search_after). But it returns count of documents in the light of search_after but not total count. This behaviour cannot be change.

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