Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MongoDBAtlasVectorSearch delete only deletes one item #871

Open
pserrer1 opened this issue May 22, 2024 · 1 comment
Open

MongoDBAtlasVectorSearch delete only deletes one item #871

pserrer1 opened this issue May 22, 2024 · 1 comment

Comments

@pserrer1
Copy link
Contributor

Currently the MongoDBAtlasVectorSearch.delete function only deletes one item. This seems wrong for me as there could be multiple items having the same ref_doc_id i.e. if the ingestion pipeline splits a node into multiple ones. Other stores have the same issue - or even a totally different behaviour (Astra uses the node.id_ instead of the ref for deletion).

I'm now kind of unsure if I have a wrong understanding of how this should work (only store documents without ingestion..?) or if the delete logic is wrong across all vector stores.

This is how I would change the MongoDBAtlasVectorStore:

  async delete(refDocId: string, deleteOptions?: any): Promise<void> {
    // changed from deleteOne to deleteMany
    await this.collection.deleteMany(
      {
        [`${this.metadataKey}.ref_doc_id`]: refDocId,
      },
      deleteOptions,
    );
  }
@justinmann
Copy link
Contributor

This should fix it: #887

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants