{"record":{"id":"abce3e5f76ed7117","repo":"langchain-ai/langchain","slug":"vectorstore-has-not-implemented-the-delete-method","errorCode":null,"errorMessage":"Vectorstore has not implemented the delete method","messagePattern":"Vectorstore has not implemented the delete method","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/core/langchain_core/indexing/api.py","lineNumber":442,"sourceCode":"    destination = vector_store  # Renaming internally for clarity\n\n    # If it's a vectorstore, let's check if it has the required methods.\n    if isinstance(destination, VectorStore):\n        # Check that the Vectorstore has required methods implemented\n        methods = [\"delete\", \"add_documents\"]\n\n        for method in methods:\n            if not hasattr(destination, method):\n                msg = (\n                    f\"Vectorstore {destination} does not have required method {method}\"\n                )\n                raise ValueError(msg)\n\n        if type(destination).delete == VectorStore.delete:\n            # Checking if the VectorStore has overridden the default delete method\n            # implementation which just raises a NotImplementedError\n            msg = \"Vectorstore has not implemented the delete method\"\n            raise ValueError(msg)\n    elif isinstance(destination, DocumentIndex):\n        pass\n    else:\n        msg = (  # type: ignore[unreachable]\n            f\"Vectorstore should be either a VectorStore or a DocumentIndex. \"\n            f\"Got {type(destination)}.\"\n        )\n        raise TypeError(msg)\n\n    if isinstance(docs_source, BaseLoader):\n        try:\n            doc_iterator = docs_source.lazy_load()\n        except NotImplementedError:\n            doc_iterator = iter(docs_source.load())\n    else:\n        doc_iterator = iter(docs_source)\n\n    source_id_assigner = _get_source_id_assigner(source_id_key)","sourceCodeStart":424,"sourceCodeEnd":460,"githubUrl":"https://github.com/langchain-ai/langchain/blob/e32fa9a52eab3b61ad7a45399bfde59b3e580fc4/libs/core/langchain_core/indexing/api.py#L424-L460","documentation":"Raised in `index()` preflight when the destination's `delete` method is still the base `VectorStore.delete` implementation. The base class deliberately makes `delete` raise `NotImplementedError`; the check `type(destination).delete == VectorStore.delete` detects subclasses that never overrode it. Running cleanup against such a store would fail mid-indexing, so it fails fast with a `ValueError` instead.","triggerScenarios":"Subclassing `VectorStore` (or a mid-tier base like `EmbeddingsStore`) and implementing `add_documents` + `similarity_search` but not `delete`, then calling `index(..., cleanup=...)`. Also triggered by cleanup=None? No — this check runs before cleanup branching in this code path when a VectorStore destination is used with this indexer version.","commonSituations":"Minimal custom stores built by copying only the search methods from an example; older third-party stores predating the `delete` requirement; wrappers that inherit delete unchanged from an intermediate class that also never implemented it.","solutions":["Override `delete` in your VectorStore subclass to call the backend's removal API.","If deletion is unsupported by design, subclass such that indexing is not used, or raise your own descriptive error.","Check for an updated version of the third-party store package — many added delete support once this check landed."],"exampleFix":"# before\nclass MyStore(VectorStore):\n    def add_documents(self, documents, **kwargs): ...\n    # delete inherited (NotImplementedError)\n\n# after\nclass MyStore(VectorStore):\n    def add_documents(self, documents, **kwargs): ...\n    def delete(self, ids=None, **kwargs):\n        self._collection.delete(ids=ids)\n        return True","handlingStrategy":"type-guard","validationCode":"from langchain_core.vectorstores import VectorStore\n\nif type(store).delete is VectorStore.delete:\n    raise TypeError(\"store has not overridden delete(); indexing cleanup would fail\")\nindex(store, docs, rm, cleanup=\"incremental\", source_id_key=\"source\")","typeGuard":"from langchain_core.vectorstores import VectorStore\n\ndef has_real_delete(store: VectorStore) -> bool:\n    return type(store).delete is not VectorStore.delete","tryCatchPattern":null,"preventionTips":["Always override delete() when subclassing VectorStore for use with indexing.","When adopting a third-party store, verify delete works before scheduling cleanup jobs."],"tags":["indexing","vector-store","delete","interface"],"backgroundTag":null,"analyzedSha":"e32fa9a52eab3b61ad7a45399bfde59b3e580fc4","analyzedAt":"2026-08-14T18:42:09.092Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}