Query rewriting or query expansion is the process of changing a user’s search query into a better one—usually by adding, removing, or rephrasing terms so a search or retrieval system can find more relevant results.
People often search with short, vague, or underspecified queries. Systems that use the raw query alone may miss relevant documents because the wording does not match the target content.
Query rewriting/expansion helps when you want better recall, better intent matching, or more robust retrieval for search, RAG, and assistant workflows. In practice, teams use it when the original query is too broad, too narrow, ambiguous, or full of shorthand that the index does not understand.
At a high level, the system takes the original query and produces one or more alternate queries.
The rewritten or expanded query can be produced in several ways:
A common pattern is to generate several candidate queries, retrieve results for each, and merge or rerank the results. That can improve recall, but it also increases the risk of drifting away from the user’s original intent, so good systems keep the rewrite tightly grounded in the source query.
Original query:
“jaguar speed”
Possible rewrite/expansion:
“jaguar animal running speed”
“jaguar car top speed”
Why this helps: the original query is ambiguous. Expansion makes the intent more specific, and the search system can surface the right kind of result.
A good rule of thumb: use query rewriting/expansion when you need better retrieval coverage, but keep it conservative and test it against real queries and relevance judgments.