Query rewriting and routing
For engineers
Turning messy user questions into good search queries: rewriting, expanding, decomposing and sending each to the right index or tool
110 questions across four stages: Understand, Apply, Solve and Judge.
Try 5 questions
Practice items, not counted towards your mastery. No account needed.
Check yourself · 1 of 5
A user's second message is "what about the cheaper one?". Why does searching with that exact text fail?
Check yourself · 2 of 5
Which question most clearly needs decomposition into sub-queries?
Check yourself · 3 of 5
Which question should a router send to a SQL source rather than the document index?
Check yourself · 4 of 5
In HyDE, what does the model write before the search?
Check yourself · 5 of 5
Why apply "year = 2023" as a metadata filter instead of leaving "2023" in the vector query?
Topics
- Rewriting follow-up questions into search queries4 min read · Resolving pronouns and chat history into a standalone query, fixing typos and adding the terms the documents actually use
- Splitting multi-part questions into sub-queries4 min read · Breaking comparisons and multi-hop questions into separate retrievals and merging the evidence before answering
- Routing a question to the right index or tool5 min read · Classifying a query by intent with structured output and sending it to a document index, SQL, an API or no retrieval at all
- HyDE, multi-query and step-back prompting5 min read · Searching with a hypothetical answer, several paraphrases or a more general question, and when each helps or adds noise
- Extracting filters from natural-language questions5 min read · Pulling dates, product names, regions and document types out of a question into structured filters for the search
Start here
- Precise Zero-Shot Dense Retrieval without Relevance Labels (HyDE) (opens in a new tab)PaperFree
Introduces searching with a generated hypothetical answer instead of the raw question.
- Query Rewriting for Retrieval-Augmented Large Language Models (opens in a new tab)PaperFree
Shows rewriting the query before retrieval as its own trainable step in a RAG pipeline.
- Measuring and Narrowing the Compositionality Gap in Language Models (Self-Ask) (opens in a new tab)PaperFree
Explains why multi-part questions fail and how asking sub-questions closes the gap.
Scenarios
Helps to know first
110 questions · last verified 2026-12