langchain-ai/langchain · error · NotImplementedError
{self.__class__.__name__} does not yet support get_by_ids.
Error message
{self.__class__.__name__} does not yet support get_by_ids. What it means
`VectorStore.get_by_ids` is an optional point-lookup API; the base class raises `NotImplementedError` naming the subclass when it is called on a store that has not implemented it. LangChain prefers explicit failure here so retrievers do not silently return empty results and mask missing data.
Source
Thrown at libs/core/langchain_core/vectorstores/base.py:145
Fewer documents may be returned than requested if some IDs are not found or
if there are duplicated IDs.
Users should not assume that the order of the returned documents matches
the order of the input IDs. Instead, users should rely on the ID field of the
returned documents.
This method should **NOT** raise exceptions if no documents are found for
some IDs.
Args:
ids: List of IDs to retrieve.
Returns:
List of `Document` objects.
"""
msg = f"{self.__class__.__name__} does not yet support get_by_ids."
raise NotImplementedError(msg)
# Implementations should override this method to provide an async native version.
async def aget_by_ids(self, ids: Sequence[str], /) -> list[Document]:
"""Async get documents by their IDs.
The returned documents are expected to have the ID field set to the ID of the
document in the vector store.
Fewer documents may be returned than requested if some IDs are not found or
if there are duplicated IDs.
Users should not assume that the order of the returned documents matches
the order of the input IDs. Instead, users should rely on the ID field of the
returned documents.
This method should **NOT** raise exceptions if no documents are found for
some IDs.
View on GitHub (pinned to e32fa9a52e)
Solutions
- Detect support before calling: `if type(store).get_by_ids is not VectorStore.get_by_ids:`.
- Implement `get_by_ids` in your subclass using the backend's fetch-by-key API.
- If unsupported, fall back to `similarity_search` with stored metadata, or track documents externally.
Example fix
# before
docs = store.get_by_ids(["abc"]) # NotImplementedError
# after
if type(store).get_by_ids is not VectorStore.get_by_ids:
docs = [] # or fallback lookup strategy
else:
docs = store.get_by_ids(["abc"]) Defensive patterns
Strategy: type-guard
Validate before calling
from langchain_core.vectorstores import VectorStore
def can_get_by_ids(store: VectorStore) -> bool:
return type(store).get_by_ids is not VectorStore.get_by_ids Type guard
from langchain_core.vectorstores import VectorStore
def supports_get_by_ids(store: VectorStore) -> bool:
"""True if the store implements point lookups."""
return type(store).get_by_ids is not VectorStore.get_by_ids Try / catch
try:
docs = store.get_by_ids(ids)
except NotImplementedError:
docs = [] # or fallback: retrieve via similarity_search and filter by id in metadata Prevention
- Feature-detect point lookups before relying on them in citation flows.
- Store document ids in metadata so a search-based fallback can emulate `get_by_ids`.
- Implement `get_by_ids` in custom stores; it is cheap over most backends and unlocks retriever tooling.
When it happens
Trigger: Calling `get_by_ids([...])` (or `aget_by_ids`, which may delegate) on stores like minimal in-memory or niche backends that only implement search methods.
Common situations: Building citation/verification flows that fetch documents by ID after a search; testing custom stores with helper code that assumes the full base API; migrating between vector store backends where one supported `get_by_ids` and the other does not.
Related errors
- `add_texts` has not been implemented for {self.__class__.__n
- delete method must be implemented by subclass.
- `add_documents` and `add_texts` has not been implemented for
- search_type of {search_type} not allowed. Expected search_ty
- The delete operation to VectorStore failed.
AI-assisted analysis of langchain-ai/langchain@e32fa9a52e (2026-08-14).
Data as JSON: /api/errors/2c8a09132e8be563.
Report an issue: GitHub.