run-llama/llama_index · error · NotImplementedError
This query engine does not support retrieve, use query direc
Error message
This query engine does not support retrieve, use query directly
What it means
BaseQueryEngine implements only query/_query and aquery/_aquery. The retrieve() method exists only for interface parity with retriever-style pipelines and always raises NotImplementedError on the base class — a query engine produces a full response, not a node list, so 'retrieve' is not a meaningful operation for it.
Source
Thrown at llama-index-core/llama_index/core/base/base_query_engine.py:63
dispatcher.event(
QueryEndEvent(query=str_or_query_bundle, response=query_result)
)
return query_result
@dispatcher.span
async def aquery(self, str_or_query_bundle: QueryType) -> RESPONSE_TYPE:
dispatcher.event(QueryStartEvent(query=str_or_query_bundle))
with self.callback_manager.as_trace("query"):
if isinstance(str_or_query_bundle, str):
str_or_query_bundle = QueryBundle(str_or_query_bundle)
query_result = await self._aquery(str_or_query_bundle)
dispatcher.event(
QueryEndEvent(query=str_or_query_bundle, response=query_result)
)
return query_result
def retrieve(self, query_bundle: QueryBundle) -> List[NodeWithScore]:
raise NotImplementedError(
"This query engine does not support retrieve, use query directly"
)
def synthesize(
self,
query_bundle: QueryBundle,
nodes: List[NodeWithScore],
additional_source_nodes: Optional[Sequence[NodeWithScore]] = None,
) -> RESPONSE_TYPE:
raise NotImplementedError(
"This query engine does not support synthesize, use query directly"
)
async def asynthesize(
self,
query_bundle: QueryBundle,
nodes: List[NodeWithScore],
additional_source_nodes: Optional[Sequence[NodeWithScore]] = None,View on GitHub (pinned to afd0fef371)
Solutions
- Call .query(query_bundle) / await .aquery(...) on query engines and use .retrieve() only on BaseRetriever objects.
- If you need nodes from a query engine, use its underlying retriever (e.g. RetrieverQueryEngine._retriever) or query then convert str(response) to a TextNode — mirroring base_retriever's own handling.
- Where an IndexNode needs a retrievable object, wrap the engine's retriever instead of the engine.
Example fix
# before
nodes = query_engine.retrieve(QueryBundle("what is this?")) # NotImplementedError
# after
response = query_engine.query("what is this?")
# or, if nodes are needed, use the underlying retriever:
nodes = retriever.retrieve(QueryBundle("what is this?")) Defensive patterns
Strategy: type-guard
Validate before calling
from llama_index.core.base.retriever import BaseRetriever
def get_nodes(obj, query_bundle):
if isinstance(obj, BaseRetriever):
return obj.retrieve(query_bundle)
return None # query engines: use query() instead Type guard
from llama_index.core.base.query_engine import BaseQueryEngine
from llama_index.core.base.retriever import BaseRetriever
def supports_retrieve(obj) -> bool:
return isinstance(obj, BaseRetriever) Prevention
- Type-branch on BaseRetriever vs BaseQueryEngine in generic pipelines.
- Pass retrievers, not engines, wherever .retrieve() will be called.
- Remember base query engines only implement query/aquery.
When it happens
Trigger: Calling query_engine.retrieve(query_bundle) on any standard query engine (RetrieverQueryEngine, etc.); generic code that receives both retrievers and query engines and uniformly calls .retrieve().
Common situations: Plugging a query engine where a retriever is expected (e.g. QueryFusionRetriever retrievers list, recursion via IndexNode expecting a retriever); helper functions typed loosely that assume the retrieve API exists.
Related errors
- This query engine does not support synthesize, use query dir
- This query engine does not support asynthesize, use aquery d
- Not supported
- This query engine does not support _query.
- This query engine does not support _aquery.
AI-assisted analysis of run-llama/llama_index@afd0fef371 (2026-08-15).
Data as JSON: /api/errors/e2f10872e064052c.
Report an issue: GitHub.