PaPoo
cover

What is query rewriting / expansion?

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.

Why it matters

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.

How it works

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:

  1. Rule-based: predefined synonym lists, stemming, spelling correction, acronym expansion, or grammar rules.
  2. Learning-based: a model predicts a better query from training data or logs.
  3. LLM-based: a language model paraphrases the query or generates multiple search variants.

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.

Tiny concrete example

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.

Common pitfalls / when NOT to use it

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.

Related terms

同じ著者の記事