Finding the returning the nth document stored in an index

I am querying an index that lists documents from a collection based on the the epoch time and a unique constraint.

If I want to retrieve a list of the latest 80 documents I am using the following query:

result = client.query(
q.paginate(
q.reverse(
q.match(
q.index("Epoch_Index"))), size=80)
)

How do I retrieve the 80th document only without using the ‘size=80’ command and parsing the results? Surely there is a more fauna-tic way to achieve this?

Thank you.

You cannot get around paginating and fetching until you have 80 items back.

If you use Reverse on the Set (before Paginate) you will reverse the entire index, and get the last item. But you can use Reverse on a Page and then get the first item.

result = client.query(
  q.Select(
    0,
    q.Reverse(
      q.Paginate(
        q.Match(q.index("Epoch_Index")),
        { size: 80 }
      )
    )
  )
)
1 Like

Ah thank you kindly. I understand. Thank you for your help.