{"record":{"id":"2c8a09132e8be563","repo":"langchain-ai/langchain","slug":"self-class-name-does-not-yet-support-get","errorCode":null,"errorMessage":"{self.__class__.__name__} does not yet support get_by_ids.","messagePattern":"(.+?) does not yet support get_by_ids\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"libs/core/langchain_core/vectorstores/base.py","lineNumber":145,"sourceCode":"\n        Fewer documents may be returned than requested if some IDs are not found or\n        if there are duplicated IDs.\n\n        Users should not assume that the order of the returned documents matches\n        the order of the input IDs. Instead, users should rely on the ID field of the\n        returned documents.\n\n        This method should **NOT** raise exceptions if no documents are found for\n        some IDs.\n\n        Args:\n            ids: List of IDs to retrieve.\n\n        Returns:\n            List of `Document` objects.\n        \"\"\"\n        msg = f\"{self.__class__.__name__} does not yet support get_by_ids.\"\n        raise NotImplementedError(msg)\n\n    # Implementations should override this method to provide an async native version.\n    async def aget_by_ids(self, ids: Sequence[str], /) -> list[Document]:\n        \"\"\"Async get documents by their IDs.\n\n        The returned documents are expected to have the ID field set to the ID of the\n        document in the vector store.\n\n        Fewer documents may be returned than requested if some IDs are not found or\n        if there are duplicated IDs.\n\n        Users should not assume that the order of the returned documents matches\n        the order of the input IDs. Instead, users should rely on the ID field of the\n        returned documents.\n\n        This method should **NOT** raise exceptions if no documents are found for\n        some IDs.\n","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/langchain-ai/langchain/blob/e32fa9a52eab3b61ad7a45399bfde59b3e580fc4/libs/core/langchain_core/vectorstores/base.py#L127-L163","documentation":"`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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before\ndocs = store.get_by_ids([\"abc\"])  # NotImplementedError\n\n# after\nif type(store).get_by_ids is not VectorStore.get_by_ids:\n    docs = []  # or fallback lookup strategy\nelse:\n    docs = store.get_by_ids([\"abc\"])","handlingStrategy":"type-guard","validationCode":"from langchain_core.vectorstores import VectorStore\n\ndef can_get_by_ids(store: VectorStore) -> bool:\n    return type(store).get_by_ids is not VectorStore.get_by_ids","typeGuard":"from langchain_core.vectorstores import VectorStore\n\ndef supports_get_by_ids(store: VectorStore) -> bool:\n    \"\"\"True if the store implements point lookups.\"\"\"\n    return type(store).get_by_ids is not VectorStore.get_by_ids","tryCatchPattern":"try:\n    docs = store.get_by_ids(ids)\nexcept NotImplementedError:\n    docs = []  # or fallback: retrieve via similarity_search and filter by id in metadata","preventionTips":["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."],"tags":["vector-store","abstract-method","retrieval"],"backgroundTag":null,"analyzedSha":"e32fa9a52eab3b61ad7a45399bfde59b3e580fc4","analyzedAt":"2026-08-14T18:42:09.092Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}