Query expansion for RAG: choosing rewriting, multiple searches, and HyDE
Query expansion changes a user's question into search-friendly wording or several queries to retrieve useful material. It can help when terms are ambiguous or users phrase things differently from the documents. But generated wording is not evidence, and it can erase original constraints such as product codes or dates. Keep the original query, use only retrieved documents as answer evidence, and compare approaches on the same query set.
Query expansion changes a user's question into search-friendly wording or several queries to retrieve useful material. It can help when terms are ambiguous or users phrase things differently from the documents. But generated wording is not evidence, and it can erase original constraints such as product codes or dates. Keep the original query, use only retrieved documents as answer evidence, and compare approaches on the same query set.
How do the three approaches differ?
| Approach | Search input | Useful when | Main risk |
|---|---|---|---|
| Query rewriting | Rephrase the original with clearer wording, synonyms, or typo correction | The wording is short or ambiguous | Names, negation, codes, or exact terms may change |
| Multi-query retrieval | Generate several distinct subquestions or phrasings and search each | The question is complex or spans several aspects | More requests and cost; duplicate or off-topic results |
| HyDE | Generate a hypothetical answer-like document and use its embedding to search real material | Query embeddings poorly match domain-document language | The synthetic text may contain plausible errors and adds generation/embedding cost |
Rewriting preserves intent while making the wording easier to search. Microsoft's current public-preview Azure AI Search feature describes generating alternative queries with a generative model and searching alongside the original. Its documentation warns that alternatives may omit exact terms from the original; check feature availability and conditions in the product docs.
Multi-query retrieval searches parallel subquestions or alternate expressions, then combines results using methods supported by the system, such as score fusion, reciprocal-rank fusion (RRF), or reranking. For example, “What are the cost and security differences between managed vector search and self-hosting?” can be split into cost and access-operations searches. Deduplicate results and check how each contributes to the original question.
HyDE (Hypothetical Document Embeddings) first generates a hypothetical document that appears to answer the question, then uses its embedding to search. Gao et al. (ACL 2023) proposed this approach while noting that the hypothetical document can hallucinate; the embedding retriever then acts as a bottleneck by finding similar material in the real corpus. The generated text guides retrieval only: it is not a factual answer or citation. The paper's results are limited to its tested models, datasets, and languages.
Preserve the original meaning before changing the query
Keep the original query alongside expansions, and distinguish what may change from constraints that must remain. Do not casually generalize product names, versions, dates, locations, quantities, quoted terms, or negation and exclusions. For a compound question, map each generated query to the subquestion it serves.
For example, rewriting “Fix error code E17 that began after June 2025, only in Product X 4.2” as “troubleshooting Product X errors” broadens retrieval but drops the version, date, and code. Preserve those constraints in the rewrite and run focused searches that verify each one. Have code or an evaluator compare the expansions against the original constraints.
An expansion model may add context needed to understand a question, but should not introduce unsearched claims as if they were evidence. A HyDE document can sound authoritative while remaining synthetic and unverified. Never cite it as support for the user's answer; pass source IDs and excerpts from actual retrieved documents to generation.
How should you compare the methods?
Use the original query alone as a baseline. Compare rewriting, multi-query retrieval, and HyDE on the same document index, embedding and ranking models, filters, top-k, and held-out questions. Keep questions used to create queries or tune prompts separate from final evaluation questions.
For retrieval, measure whether relevant evidence appears near the top (for example, Recall@k), irrelevant-result rate, duplicates, source diversity, latency, and cost. Also evaluate final RAG answers for evidence accuracy, citation linkage, dropped constraints, and unsupported claims. Higher retrieval recall can still worsen answer accuracy or cost, so do not decide from one metric.
| Symptom | Diagnosis and next step |
|---|---|
| Expansion drifts from the original | Always search the original too; enforce preserved constraints in prompt or code |
| Exact code or name disappears | Keep exact tokens as required terms or always merge original-query results |
| Queries return the same documents | Make subquestions meaningfully distinct; compare deduplication and rank fusion |
| HyDE text contains errors | Never use synthetic text as answer evidence; provide only real results to generation |
| Recall rises but answer correctness falls | Inspect added false candidates and evidence links; reevaluate with precision and answer-quality guardrails |
| Cost or latency increases | Expand only where query-level gains are demonstrated; measure parallelism, caching, and call limits |
Expansion is an option to test, not a guarantee of better search. A simple, precise question may work best as written. Rewriting can suit ambiguity, multiple searches can suit compound questions, and HyDE is worth testing when domain phrasing differs. Choose using held-out queries and measures of both retrieved evidence and final answers.
Sources
[Wang et al., “Query2doc: Query Expansion with Large Language Models” (EMNLP 2023)](https://aclanthology.org/2023.emnlp-main.585/) — expanding sparse and dense retrieval queries with generated pseudo-documents; results are limited to the paper's data and setup.
[Gao et al., “Precise Zero-Shot Dense Retrieval without Relevance Labels” (ACL 2023)](https://aclanthology.org/2023.acl-long.99/) — HyDE generation, embedding retrieval, hallucination caveat, and experimental scope.
[Microsoft Learn: Rewrite queries with semantic ranker in Azure AI Search](https://learn.microsoft.com/en-us/azure/search/semantic-how-to-query-rewrite) — Azure preview rewrite behavior and possible loss of exact original terms. Checked 2026-11-23.
[Microsoft Learn: Agentic retrieval overview](https://learn.microsoft.com/en-us/azure/search/search-agentic-retrieval-concept) — Azure concept for handling complex questions with multiple subqueries; behavior depends on documented product support and date.