RAG query routing is the practice of deciding, for each incoming question, which index, data source or retrieval path should handle it, instead of sending every question through the same pipeline. A question about last month’s sales belongs in a structured database, a question about company policy belongs in the document index, and a question with no answer in your corpus should not be forced through retrieval at all. The short answer is that good routing improves accuracy, speed and cost at the same time, because each question is answered from the source best equipped to handle it.
Most retrieval systems start simple: one index, one retriever, one pipeline for everything. That works while the corpus is small and uniform. It starts to fail when the corpus grows to cover different kinds of knowledge, because no single retrieval strategy is best for all of them. Routing is the fix. It adds a decision step before retrieval, and that step is usually cheap compared with the mistakes it prevents.
Key takeaways
- RAG query routing sends each question to the index, tool or pipeline best suited to answer it.
- Common routes include document search, structured databases, web search and direct generation without retrieval.
- Routing decisions can be made by rules, by a small classifier or by a language model acting as a router.
- A bad route is usually worse than no routing, so measure misroute rates before shipping.
- Always keep a fallback route, and log every decision so routing mistakes can be found and fixed.
Why one pipeline is not enough
Different questions need different kinds of evidence. A factual question about a product specification needs a precise passage from a manual. A question that asks for a total, an average or a trend needs a database query, not a paragraph. A question about recent events needs fresh information that may not exist in your indexed documents at all. Sending all three through the same vector search guarantees that at least one of them gets a poor answer.
Routing also controls cost. Vector search over a large index, followed by generation from a large model, is expensive for questions that a small lookup could have answered in milliseconds. A routing layer can send simple questions to cheap paths and reserve the expensive paths for questions that need them. Over thousands of queries a day, that difference is substantial.
The main routing strategies
The simplest strategy is rule-based routing. Questions are matched against patterns: if the question contains a date range and words such as “total” or “average”, send it to the database; if it mentions a product name, send it to the manual index. Rules are transparent and easy to debug, and they work well when the question types are distinct and stable. Their weakness is maintenance: as the product grows, the rule set grows with it, and rules start to conflict.
The second strategy is classifier routing. A small trained model reads the question and predicts which route it belongs to. Classifiers handle phrasing variation better than rules, because they learn from examples rather than exact patterns. They need labelled training data, which means someone must collect and label a few hundred example questions per route. That upfront cost pays off quickly if question volume is high.
The third strategy is to use a language model as the router. The model reads the question and a short description of each available route, then picks one. This is the most flexible option, because adding a route is as simple as writing a new description, and the router can handle questions it has never seen before. It is also the slowest and most expensive option, and its decisions are harder to explain than a classifier’s. Many teams use it for complex routing and a classifier or rules for the simple cases.
What routes can you offer?
The most common route is document retrieval: vector search over your indexed corpus, followed by generation grounded in the retrieved passages. This is the default RAG path and should handle the majority of questions in a knowledge-heavy system. Everything else exists to catch the questions this path handles badly.
Structured data is the second route. Questions about numbers, dates and lists are usually better answered by querying a database or spreadsheet than by searching text. A router that recognises analytical questions and sends them to a text-to-query path can turn a vague paragraph answer into an exact figure. The key is a reliable translation from question to query, and a check that the query ran against the right tables.
Web search is the third route, for questions about the world outside your corpus. If your documents are a year old and the user asks about a change made last week, no amount of retrieval over stale documents will help. A router that detects recency signals and sends those questions to a web search keeps the system honest instead of letting it answer from outdated material.
The fourth route is direct generation with no retrieval at all. Some questions do not need documents: simple explanations, brainstorming and general knowledge questions are often answered better without retrieval, because retrieved passages can distract the generator with irrelevant detail. Routing these questions away from retrieval also saves cost and latency.
| Routing strategy | How it decides | Strengths | Weaknesses | Best for |
|---|---|---|---|---|
| Rule-based | Patterns and keywords | Transparent, fast, easy to debug | Brittle, maintenance grows with scale | Small systems with distinct question types |
| Classifier | Small trained model | Handles phrasing variation, fast at run time | Needs labelled training data | High-volume systems with stable routes |
| Language model router | Model reads route descriptions | Flexible, handles unseen questions | Slow, costly, hard to explain | Complex routing with many routes |
| Semantic routing | Embedding similarity to examples | No training, easy to extend | Struggles with subtle distinctions | Teams adding routes frequently |
What happens when routing goes wrong
A misroute is usually worse than no routing. If a question about sales figures is sent to the document index, the system will find a passage that mentions sales and generate a confident answer from it, even though the correct answer was a number in a database. The user receives a plausible-sounding wrong answer, which is harder to catch than an obvious failure.
Misroutes also compound. A router that sends too many questions to the expensive path wastes money, while one that sends too many to the cheap path degrades quality. Because the router sits at the start of the pipeline, its errors affect everything downstream, and small error rates matter: a router that is wrong five per cent of the time will produce a wrong answer for one in twenty users.
The fix is measurement. Log every routing decision with the question, the chosen route and the eventual outcome, and review the mistakes regularly. Pay special attention to questions near the boundary between two routes, because those are where classifiers and language models are least confident. A confidence threshold that sends uncertain questions to a safe default route is often worth more than a slightly better router.

Designing routes for your own system
Start by looking at real questions. Pull a sample of a few hundred from your logs, support tickets or user interviews, and sort them into groups by what kind of evidence would answer them. If most questions fall into one group, you may not need routing yet. If they split into three or four distinct groups, routing will help.
Define each route by its purpose, not by its technology. “Questions about numbers” is a better route definition than “the SQL path”, because it keeps the focus on what the user needs. Write a one-sentence description of each route, and test whether a colleague can sort new questions into routes using only those descriptions. If they cannot, the routes are not clear enough.
Build the fallback first. Before you add clever routing, decide what happens when the router is unsure or when every route fails. A graceful fallback, such as running the default document search and being honest about uncertainty, keeps the system usable while you improve the router. Systems without a fallback fail loudly; systems with one degrade gracefully.
Keep the number of routes small. Each route adds testing surface, monitoring burden and maintenance cost. Three or four well-chosen routes beat eight overlapping ones. Add a new route only when you can show, with real questions, that an existing route handles them badly.
Measuring whether routing helps
The simplest measure is answer accuracy before and after routing, on a fixed test set of real questions. If routing does not improve accuracy, it is not earning its complexity. Measure per route as well as overall, because a router can improve the average while making one route worse.
Also measure the misroute rate directly. Have a human review a sample of routed questions and judge whether each went to the right route. This is more work than measuring accuracy, but it tells you where the router itself is failing, rather than mixing router errors with retrieval and generation errors.
Finally, watch for drift. Question patterns change as users learn what the system can do, and a router trained on last year’s questions may misroute this year’s. Re-check routing accuracy regularly, and retrain or update the router when the question mix shifts.
Checklist: adding query routing to a RAG system
- Sample real questions and group them by the evidence needed to answer them.
- Define three or four routes by purpose, each with a one-sentence description.
- Build the fallback route before adding any clever routing.
- Choose the simplest router that handles your question types, and upgrade only when it fails.
- Collect labelled examples for each route before training a classifier.
- Set a confidence threshold that sends uncertain questions to the safe default.
- Log every routing decision with the question, route and outcome.
- Measure answer accuracy before and after routing on a fixed test set.
- Review misroutes weekly at first, and fix the most common error pattern each time.
- Re-check routing accuracy whenever the question mix changes.
Frequently asked questions
Is RAG query routing the same as query rewriting?
No. Query rewriting improves a question before it is sent to retrieval, for example by expanding abbreviations or adding context. Routing decides where the question goes. The two often work together: a question can be routed first, then rewritten for the route it was sent to. Our guide to RAG query rewriting explains the rewriting step in detail.
When does routing become worth the effort?
When your corpus covers clearly different kinds of knowledge, or when some questions need databases, web search or no retrieval at all. If nearly all questions are answered well by one document index, routing adds complexity without benefit.
Can a language model route queries reliably?
Yes, for complex routing with many routes, but it is the slowest and most expensive option. Many teams use a classifier or rules for common cases and reserve the language model router for questions the simpler methods cannot decide.
What is the safest fallback route?
Usually the default document search, combined with honesty about uncertainty. The system should answer from retrieved passages where possible and say clearly when it cannot find an answer, rather than guessing.
How many routes should a system have?
As few as possible. Three or four well-chosen routes beat eight overlapping ones. Add a route only when real questions show that an existing route handles them badly.
How do I know if my router is misrouting?
Log every decision and have a human review a sample regularly. A misroute rate above a few per cent deserves attention, especially for questions near the boundary between two routes. Good RAG architecture makes these logs easy to inspect, and retrieval coverage checks help confirm each route is finding what it should.







