Skip to main content

Query Rewriting

Query rewriting is a retrieval preprocessing step that transforms the user's question before it is sent to the retriever. Common rewrites: decompose a compound question into sub-questions, expand short queries with synonyms or related terms, pull missing context from conversation history into a standalone query, or translate the query into a form that looks more like the documents being searched. Rewriting can be rule-based, but in 2026 it is usually model-generated — a small LLM call whose only job is to rewrite the query. A single under-specified question often retrieves poorly even from a good index; a rewritten version that spells out the implicit subject and adds obvious synonyms typically retrieves materially more relevant documents.

Example

In a multi-turn chat support session, a user asks "and what about refunds?" after earlier asking about subscription cancellations. Sent directly to the retriever, the query returns generic refund-policy pages for the whole product line. A rewriting step uses the conversation history to rewrite the query to "refund policy for canceled monthly subscriptions" — the retriever now returns the specific policy page for that case, and the final answer is exact rather than generic.

Put this into practice

Build polished, copy-ready prompts in under 60 seconds with SurePrompts.

Try SurePrompts