Skip to main content

What are Query Engines?

Query engines process questions over your data and return synthesized answers. Unlike chat engines, query engines:
  • Handle single-turn questions (no chat history)
  • Support complex query patterns (routing, sub-questions)
  • Provide structured responses with source citations
  • Enable advanced retrieval strategies

Core Query Engine Types

RetrieverQueryEngine

The fundamental query engine that retrieves and synthesizes:

Simple Query Engine from Index

The easiest way to create a query engine:

SubQuestionQueryEngine

Breaks complex questions into sub-questions:

RouterQueryEngine

Routes queries to the best query engine:

Complete Working Example

Here’s a production-ready query engine:

Response Synthesis

Query engines use response synthesizers to combine retrieved chunks:

Synthesis Modes

Using Custom Synthesizers

Streaming Synthesis

Stream responses as they’re generated:

Advanced Query Patterns

Sub-Question Decomposition

Break complex queries into simpler sub-questions:

Router-Based Selection

Automatically choose the best query engine:

Query Engine Configuration

Retrieval Parameters

Custom Retrievers

Post-Processing

Add post-processors to refine results:

Choosing the Right Query Engine

Low-Level Query Pipeline

For maximum control, build the query pipeline manually:

Next Steps