Additional results (paging equivalent)

Hi,

Assuming I have a namespace of financial documents, now assuming I’m querying it with some query (e.g. "stock summary of company X over 2023) with topk of 5.

Now assuming the results are great and relevant but I would like to fetch additional 5 results (sort of pagination on traditional DBs)

How may I achieve that without saving any applicative memory/state ?

Thanks

Hi @falkor,

Thanks for your question!

There isn’t a built-in paging mechanism equivalent to traditional databases where you can fetch results in chunks (e.g., using OFFSET and LIMIT). However, you can simulate paging by adjusting your queries.

To retrieve additional results beyond the initial query, you’ll need to manage the topK value, which specifies the number of results returned. To implement paging, you can:

  1. Start with a topK value for the initial query.
  2. For subsequent “pages,” adjust the query to return the next set of results.

You’ll need to handle this logic client-side. For example, after fetching the top N results, you could store the highest score from that result set and adjust your next query to start just below that score, ensuring non-overlapping results.

You could also experiment with querying for a higher value of topK, which supports values up to 10,000 and then doing your filtering or pagination client-side.

You may need to experiment a bit with different values for topK.

Hope that helps!

Best,
Zack

Hi @ZacharyProser

Thanks for your honest reply

This methodology you offered indeed will probably do the job, but I’m afraid:

  1. It is not pagination, it’s fetching the k results and do “pagination” on the client side. The whole purpose of pagination is to avoid storing memory over the client side and let the DB handle all the pagination process (with offset and limit or equivalent mechanism)
  2. Support the workaround you offered through RAG and lang chain/flowise is almost impossible.
  3. It is very basic from DB (whatever type it is) to support such mechanism
  4. Per my little research I’ve done this feature has high demand from the community.

Thanks