0

I am trying to delete all the data points that are associated with a particular email Id, but I am encountering the following error.

source code:

app.get('/cleanUpResources', async (req, res) => {
    const _id = req.query.email;
    const embeddings = new VertexAIEmbeddings({
        model: "text-embedding-004",
    });

    const vectorStore = await QdrantVectorStore.fromExistingCollection(embeddings, {
        url: <url>,
        apiKey: <api-key>,
        collectionName: 'pdf-docs',
    });

    // Delete all points with payload field 'id' equal to req.body.email
    await vectorStore.delete({
        filter: {
            must: [
                {
                    key: "id",
                    match: { value: JSON.stringify(_id) },
                },
            ],
        },
    });

    return res.json({ message: `Deleted all points with id: ${id}` });
})

Error:

Error: Bad Request
    at Object.fun [as deletePoints] (file:///C:/Users/abhis/OneDrive/Desktop/PROJECTS/PDF-RAG/server/node_modules/@qdrant/openapi-typescript-fetch/dist/esm/fetcher.js:169:23)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async QdrantClient.delete (file:///C:/Users/abhis/OneDrive/Desktop/PROJECTS/PDF-RAG/server/node_modules/@qdrant/js-client-rest/dist/esm/qdrant-client.js:628:26)
    at async QdrantVectorStore.delete (file:///C:/Users/abhis/OneDrive/Desktop/PROJECTS/PDF-RAG/server/node_modules/@langchain/qdrant/dist/vectorstores.js:140:13)
    at async file:///C:/Users/abhis/OneDrive/Desktop/PROJECTS/PDF-RAG/server/app.js:73:5

qDrant DB Collection structure:

metadata: {
"source":"uploads\1753380027445-401326695-CT20244465298_Appl…"
"pdf":{}
"loc":{}
"id":"<email_address>"
}

I have also gone through the documentation but not able to debug this. https://v03.api.js.langchain.com/classes/_langchain_qdrant.QdrantVectorStore.html#delete

https://qdrant.tech/documentation/concepts/points/#delete-points

1 Answer 1

1

Can you please confirm that req.query.email is not undefined? That’s likely why JSON.stringify(_id) is also returning undefined.

Note that the id is nested within the metadata object. So the key should be metadata.id, as per https://qdrant.tech/documentation/concepts/filtering/#nested-key.

Also, you don't need to use JSON.stringify if the input is already a string. It will wrap the string in extra quotes and not match the points.

Sign up to request clarification or add additional context in comments.

3 Comments

Yes the req.query.email is not undefined, and I have also changed the key to metadata.id, I am getting this error: Error: Bad Request at Object.fun [as deletePoints] (file:///C:/Users/abhis/OneDrive/Desktop/PROJECTS/PDF-RAG/server/node_modules/@qdrant/openapi-typescript-fetch/dist/esm/fetcher.js:169:23) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async QdrantClient.delete (file:///C:/Users/abhis/OneDrive/Desktop/PROJECTS/PDF-
I tried a request same as yours and could get a similar error only with JSON.stringify(_id) returning undefined.
I recommend you log the entire delete request object to inspect.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.