(Serverless) How do I know when my vectors become available after insertion?

Hi,

When you insert vectors into a serverless index, it takes some time for those vectors to become available for querying. This is a known issue, but the recommended workaround is to repeatedly call describe_index_stats after the insertion until the total # of vectors in the namespace matches what you’d expect.

This works fine until you have multiple jobs inserting vectors into the same namespace, e.g. if you are indexing different groups of documents at the same time. The delta in total vector count won’t tell you if a specific indexing job is finished or not. This wouldn’t be a problem if I could use metadata filters in describe_index_stats, since I could just filter by job ID, but filters aren’t available in serverless indexes for some reason.

What should I do here? I could repeatedly fetch every vector in the index until I get a valid response, but this seems ridiculous if you’re dealing with millions of vectors. Please let me know if there’s a better way of knowing when my vectors will actually become usable after insertion.

Thank you.

1 Like

Hi @jonathan3. Thank you for this question and sorry it’s taken so long to response.

I just posted an answer with relevant recommendations here. But to save you time:

If it’s essential for your use case to lock reads (queries) until you can ensure data is available, we recommend either fetching by the ID of the record or comparing the LSN of the write to the LSN of a query. Every operation gets an LSN (log sequence number), and they are monotonically increasing, so as soon as the LSN of the query is higher than the LSN of the write, your data is available.

I know the docs recommend repeatedly calling describe_index_stats, which isn’t a practical or useful approach in cases like yours. I’ll make sure we update our docs.

Hope that helps. Please let me know.

Best,
Jesse