run-llama/llama_index · error · NotImplementedError
clear not implemented
Error message
clear not implemented
What it means
`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.
Source
Thrown at llama-index-core/llama_index/core/vector_stores/types.py:415
node_ids: Optional[List[str]] = None,
filters: Optional[MetadataFilters] = None,
**delete_kwargs: Any,
) -> None:
"""Delete nodes from vector store."""
raise NotImplementedError("delete_nodes not implemented")
async def adelete_nodes(
self,
node_ids: Optional[List[str]] = None,
filters: Optional[MetadataFilters] = None,
**delete_kwargs: Any,
) -> None:
"""Asynchronously delete nodes from vector store."""
self.delete_nodes(node_ids, filters)
def clear(self) -> None:
"""Clear all nodes from configured vector store."""
raise NotImplementedError("clear not implemented")
async def aclear(self) -> None:
"""Asynchronously clear all nodes from configured vector store."""
self.clear()
@abstractmethod
def query(self, query: VectorStoreQuery, **kwargs: Any) -> VectorStoreQueryResult:
"""Query vector store."""
async def aquery(
self, query: VectorStoreQuery, **kwargs: Any
) -> VectorStoreQueryResult:
"""
Asynchronously query vector store.
NOTE: this is not implemented for all vector stores. If not implemented,
it will just call query synchronously.
"""
return self.query(query, **kwargs)View on GitHub (pinned to afd0fef371)
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.
Example fix
# before
store.clear() # NotImplementedError
# after
from llama_index.core.vector_stores import BaseVectorStore
if type(store).clear is not BaseVectorStore.clear:
store.clear()
elif isinstance(store, SimpleVectorStore):
store.data = SimpleVectorStoreData() # fresh in-memory state Defensive patterns
Strategy: fallback
Validate before calling
from llama_index.core.vector_stores import BaseVectorStore
def supports_clear(store) -> bool:
return type(store).clear is not BaseVectorStore.clear Try / catch
try:
store.clear()
except NotImplementedError:
store.data = SimpleVectorStoreData() # or recreate the store/collection Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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().
Related errors
- SimpleVectorStore does not store nodes directly.
- get_nodes not implemented
- delete_nodes not implemented
- Vector store integrations that store text in the vector stor
- Cannot filter stores that were persisted without metadata. P
AI-assisted analysis of run-llama/llama_index@afd0fef371 (2026-08-15).
Data as JSON: /api/errors/d12adede82ccbb6b.
Report an issue: GitHub.