{"record":{"id":"e2f10872e064052c","repo":"run-llama/llama_index","slug":"this-query-engine-does-not-support-retrieve-use-q","errorCode":null,"errorMessage":"This query engine does not support retrieve, use query directly","messagePattern":"This query engine does not support retrieve, use query directly","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/base/base_query_engine.py","lineNumber":63,"sourceCode":"        dispatcher.event(\n            QueryEndEvent(query=str_or_query_bundle, response=query_result)\n        )\n        return query_result\n\n    @dispatcher.span\n    async def aquery(self, str_or_query_bundle: QueryType) -> RESPONSE_TYPE:\n        dispatcher.event(QueryStartEvent(query=str_or_query_bundle))\n        with self.callback_manager.as_trace(\"query\"):\n            if isinstance(str_or_query_bundle, str):\n                str_or_query_bundle = QueryBundle(str_or_query_bundle)\n            query_result = await self._aquery(str_or_query_bundle)\n        dispatcher.event(\n            QueryEndEvent(query=str_or_query_bundle, response=query_result)\n        )\n        return query_result\n\n    def retrieve(self, query_bundle: QueryBundle) -> List[NodeWithScore]:\n        raise NotImplementedError(\n            \"This query engine does not support retrieve, use query directly\"\n        )\n\n    def synthesize(\n        self,\n        query_bundle: QueryBundle,\n        nodes: List[NodeWithScore],\n        additional_source_nodes: Optional[Sequence[NodeWithScore]] = None,\n    ) -> RESPONSE_TYPE:\n        raise NotImplementedError(\n            \"This query engine does not support synthesize, use query directly\"\n        )\n\n    async def asynthesize(\n        self,\n        query_bundle: QueryBundle,\n        nodes: List[NodeWithScore],\n        additional_source_nodes: Optional[Sequence[NodeWithScore]] = None,","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/base/base_query_engine.py#L45-L81","documentation":"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.","triggerScenarios":"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().","commonSituations":"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.","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."],"exampleFix":"# before\nnodes = query_engine.retrieve(QueryBundle(\"what is this?\"))  # NotImplementedError\n\n# after\nresponse = query_engine.query(\"what is this?\")\n# or, if nodes are needed, use the underlying retriever:\nnodes = retriever.retrieve(QueryBundle(\"what is this?\"))","handlingStrategy":"type-guard","validationCode":"from llama_index.core.base.retriever import BaseRetriever\n\ndef get_nodes(obj, query_bundle):\n    if isinstance(obj, BaseRetriever):\n        return obj.retrieve(query_bundle)\n    return None  # query engines: use query() instead","typeGuard":"from llama_index.core.base.query_engine import BaseQueryEngine\nfrom llama_index.core.base.retriever import BaseRetriever\n\ndef supports_retrieve(obj) -> bool:\n    return isinstance(obj, BaseRetriever)","tryCatchPattern":null,"preventionTips":["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."],"tags":["query-engine","api-misuse","retriever"],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}