Skip to content

Query rewriting

Query rewriting transforms a user’s question into wording that a search system may retrieve more effectively. A rewrite may add corpus terminology, correct spelling, resolve conversation references, or create several focused queries.

User: Can I send it back after two weeks?
Rewrite: return policy after 14 days

The rewrite matches likely policy language. It might also lose an exact order ID or misunderstand what “it” means.

Search with the original query and one or more rewrites, record each version, and compare retrieval quality with and without rewriting. Microsoft’s query-rewrite documentation follows this original-plus-rewrites pattern and warns about losing exact terms such as product codes.1

Rewriting adds another fallible model operation, latency, and cost. Use it for a measured query-understanding problem, not as a mandatory RAG stage.

  1. Microsoft, query rewriting in Azure AI Search. The documented API is vendor-specific and currently preview.