{"record":{"id":"d12adede82ccbb6b","repo":"run-llama/llama_index","slug":"clear-not-implemented","errorCode":null,"errorMessage":"clear not implemented","messagePattern":"clear not implemented","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/vector_stores/types.py","lineNumber":415,"sourceCode":"        node_ids: Optional[List[str]] = None,\n        filters: Optional[MetadataFilters] = None,\n        **delete_kwargs: Any,\n    ) -> None:\n        \"\"\"Delete nodes from vector store.\"\"\"\n        raise NotImplementedError(\"delete_nodes not implemented\")\n\n    async def adelete_nodes(\n        self,\n        node_ids: Optional[List[str]] = None,\n        filters: Optional[MetadataFilters] = None,\n        **delete_kwargs: Any,\n    ) -> None:\n        \"\"\"Asynchronously delete nodes from vector store.\"\"\"\n        self.delete_nodes(node_ids, filters)\n\n    def clear(self) -> None:\n        \"\"\"Clear all nodes from configured vector store.\"\"\"\n        raise NotImplementedError(\"clear not implemented\")\n\n    async def aclear(self) -> None:\n        \"\"\"Asynchronously clear all nodes from configured vector store.\"\"\"\n        self.clear()\n\n    @abstractmethod\n    def query(self, query: VectorStoreQuery, **kwargs: Any) -> VectorStoreQueryResult:\n        \"\"\"Query vector store.\"\"\"\n\n    async def aquery(\n        self, query: VectorStoreQuery, **kwargs: Any\n    ) -> VectorStoreQueryResult:\n        \"\"\"\n        Asynchronously query vector store.\n        NOTE: this is not implemented for all vector stores. If not implemented,\n        it will just call query synchronously.\n        \"\"\"\n        return self.query(query, **kwargs)","sourceCodeStart":397,"sourceCodeEnd":433,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/vector_stores/types.py#L397-L433","documentation":"`BaseVectorStore.clear()` is another base-class stub intended to wipe all nodes from a store; the base implementation unconditionally raises NotImplementedError. Stores that cannot (or do not yet) implement full wipes — including SimpleVectorStore — leave it unoverridden. The async `aclear()` delegates to it and fails the same way.","triggerScenarios":"Calling `store.clear()` or `await store.aclear()` in test teardown or reset flows on a store integration that did not override clear(); e.g. resetting a SimpleVectorStore-backed index between test cases.","commonSituations":"pytest fixtures that clear state between tests; CLI 'reset index' commands; multi-tenant flows that wipe per-tenant collections; backend swaps where the previous store supported clear().","solutions":["Detect support first: `type(store).clear is not BaseVectorStore.clear`.","For SimpleVectorStore, replace state directly: `store.data = SimpleVectorStoreData()` or rebuild the store object.","Use `store.delete(ref_doc_id)` per document, or delete and recreate the underlying persistence/collection for stores without clear().","In test fixtures, construct a fresh store per test instead of clearing."],"exampleFix":"# before\nstore.clear()  # NotImplementedError\n\n# after\nfrom llama_index.core.vector_stores import BaseVectorStore\nif type(store).clear is not BaseVectorStore.clear:\n    store.clear()\nelif isinstance(store, SimpleVectorStore):\n    store.data = SimpleVectorStoreData()  # fresh in-memory state","handlingStrategy":"fallback","validationCode":"from llama_index.core.vector_stores import BaseVectorStore\n\ndef supports_clear(store) -> bool:\n    return type(store).clear is not BaseVectorStore.clear","typeGuard":null,"tryCatchPattern":"try:\n    store.clear()\nexcept NotImplementedError:\n    store.data = SimpleVectorStoreData()  # or recreate the store/collection","preventionTips":["Build fresh stores per test instead of clearing shared ones.","Implement a reset routine per backend (drop collection / new store object).","Probe clear() support once and cache the result per store class."],"tags":["vector-store","not-implemented","lifecycle","python"],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}