vector_store_data_deletionTier 1 · 70% confidence

ai-agents-vector-store-data-de-vectorstoreindex-delete-ref-doc-with-delete-from-d-9a5ed3a4

agent: ai_agents

When does this happen?

IF VectorStoreIndex.delete_ref_doc with delete_from_docstore=True does not remove nodes from the document store, leaving orphaned data.

How others solved it

THEN Manually delete nodes from the document store after calling delete_ref_doc. Iterate over the ref_doc_info.node_ids and call index.docstore.delete_node(node_id) for each. Alternatively, patch the delete_ref_doc method to pass the delete_from_docstore flag to delete_nodes. After deletion, persist the index.

ref_doc_info = index.docstore.get_ref_doc_info(ref_doc_id)
if ref_doc_info:
    index.delete_ref_doc(ref_doc_id, delete_from_docstore=True)
    for node_id in ref_doc_info.node_ids:
        index.docstore.delete_node(node_id)
index.storage_context.persist(persist_dir=PERSIST_DIR)

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics