What problem does LlamaIndex's `RouterQueryEngine` solve that a single `QueryEngine` cannot?
RouterQueryEngine picks among several sub-engines (vector, SQL, summary) per query so one front door can serve structurally different question types.
Picture the front desk at a hospital. A single QueryEngine is one specialist with one toolkit. Great for the questions they know, useless for the rest. RouterQueryEngine is a triage nurse. You arrive with any question; she listens, decides whether you need radiology, the pharmacy, or general practice, and sends you to the right room. The departments have completely different tools, X-ray machines, pill counters, stethoscopes, but the patient only sees one front door. The router does not retrieve anything itself. It picks the engine that should retrieve, and that engine handles the rest.
Detailed answer & concept explanation~5 min readEverything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
4 min: why one Index cannot serve all shapes, how the Selector picks, what differentiates LLM-based from embedding-based, and how to calibrate sub-engine descriptions.
Real products, models, and research that use this idea.
- LlamaIndex's official tutorials use RouterQueryEngine to combine a summary index and a vector index over the same documents for 'summarise the report' vs 'what does it say about X' questions.
- Notion AI's document Q&A combines whole-document summarisation, page-level retrieval, and structured property queries. Exactly the heterogeneous workload RouterQueryEngine targets.
- Replit's repo assistant routes 'what does this function do' (semantic) vs 'find all callers of X' (graph / structured). Different retrieval shapes behind one front door.
- LangChain's MultiRetrievalQAChain and RouterRunnable solve similar dispatch patterns; the underlying problem (one Index per shape) is framework-agnostic.
What an interviewer would ask next. Try answering before peeking at the approach.
QHow would you compare RouterQueryEngine to a SubQuestionQueryEngine?
QWhat does the Selector's prompt look like in practice?
Don't say thisRed flags and common mistakes that signal junior thinking. Click to expand.
Red flags and common mistakes that signal junior thinking. Click to expand.
Building one fat vector index for every kind of question, summarisation, lookup, structured query, and getting bad answers because the index shape only fits one question type.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.
Same topic, related formats. Practice these next.