How to update data in Qdrant using langchain.js?

174 Views Asked by At

I am using langchain.js QdrantVectorStore to perform CRUD operations in Qdrant collection. I see that there are many options available in js QdrantVectorStore to add data to Qdrant but I don't see any method to update points in a cluster using langchain.js. I know I can use Qdrant js sdk to perform Updates to points but I prefer doing it using QdrantVectorStore for the following reasons:

  1. it simply takes the text and Embedding model and do the rest. we don't have to manually convert text to embeddings or vectors.
  2. Qdrant has different APIs to update vectors and payload, Since QdrantVectorStore stores the actual text in payload.content along with the vectors so using qdrant sdk I will have to perfrom the vector and payload updates seperately with two API calls.

Although using Qdrant vector stores allows writing a clean code.

This reddit post suggests using add_documents even for update but that suggestion is for langchain.py not for js. But I tried something similar in langchain.js, I tried to use QdrantVectorStore.addDocuments() to update data but I couldn't find a way to pass pointId[] to specify which point to update. I also checked the types and interfaces for QdrantVectorStore.addDocuments() so I found this

type QdrantAddDocumentOptions = {
    customPayload: Record<string, any>[];
};
addDocuments(documents: Document[], documentOptions?: QdrantAddDocumentOptions): Promise<void>;

As a last resort I also tried passing an array of pointIds in customPayload but that didn't work. it was simply creating a point in cluster with the ids I passed in customPayload.

0

There are 0 best solutions below