← Back to concept explainers

Concept Fable

Query rewriting

Conclusion first:Query Rewriting is rewriting a user's original question into a form better suited to retrieval, database queries or tool calls. It can resolve references, standardize terminology, split complex questions, generate multiple queries and improve RAG recall quality. The risk is that rewriting changes intent or introduces false premises, so the original query must be preserved, the rewriting process recorded, and evaluation done in high-risk scenarios.

Query Rewriting · Retrieval

Read the story first. There is no rush to give a definition here; let the question grow on its own first.

Fable

Rewrite complaints into questions the archive can understand

At the wayfinding pavilion, outsiders often phrased their questions vaguely: "How do I get to the place that sells blue cloth?" "I'm looking for the old man who fixed umbrellas last time." If the pavilion clerk searched the road register by the original words, nine times out of ten nothing would be found. The road register only recognized street names, shop names, and registration numbers—not fragments of people's memories.

At first the pavilion guard could only ask questions back, and the line grew longer and longer. Later he learned to rewrite the guest's words into clues the route register could recognize: blue cloth might be Zhou's cloth shop on Dyehouse Street, the umbrella repairman might be Master Hu at South Bridge. Lookup speed immediately improved.

Rewriting can also go wrong. Once a customer said “the pharmacy by the white tower,” and the pavilion guard changed it to White Tower Street Pharmacy, but the real location was the back gate of White Tower Temple. The more urgent the customer, the shorter the original words, and the less the pavilion guard could act on his own judgment.

The old pavilion chief set the rule: what can be determined should be converted into standard place names; what is ambiguous should first be clarified with follow-up questions; for important assignments, keep both the original words and the rewritten clues for search. The problem with the first fix was that it pursued only findability, without preserving what the person originally wanted to ask.

Later the post-station runner would break a complaint into several possibilities. When a guest said "that inn that cheated me last time," he first asked whether it was for sending a letter, changing horses, or lodging; if it might point to two establishments, he listed both leads instead of choosing only the one that sounded right.

The wayfinding pavilion found the right route more often, and arguments decreased. Guests still used their own wording, and the route book still used its own numbering; in between, someone was needed who could translate, ask follow-up questions and preserve ambiguity.

Asking well does not necessarily mean dropping the original words unchanged into the ledger. Organizing a person's vague phrasing into a queryable, matchable question often determines whether the right answer can be found; but once rewriting goes too far, it can also lead a person to the wrong street corner.

Later, the old pavilion chief posted the wrong-route cases on the wall. Each time a rewrite misled someone onto the wrong path, he recorded the original words, the rewrite, the missing follow-up question, and the correct location. The pavilion officers gradually learned that a good rewrite should help with the search while also respecting uncertainty; when something is unclear, ask first before writing. In time, the route-asking pavilion saw far fewer wasted journeys, and the route register was no longer dragged down by vague questions.

Reveal

This story is about: query rewriting

Query Rewriting is rewriting a user's original question into a form better suited to retrieval, database queries or tool calls. It can resolve references, standardize terminology, split complex questions, generate multiple queries and improve RAG recall quality. The risk is that rewriting changes intent or introduces false premises, so the original query must be preserved, the rewriting process recorded, and evaluation done in high-risk scenarios.

What matters is that it is not just a term, but a structural problem that repeatedly appears in real AI / Agent systems. Understanding it lets you judge when to add a model, when to change a process, and when to add governance.

Metaphor mapping

  • Vague complaint: the original user problem
  • Scribe backend rewrite: the query rewriting module
  • Keyword-based, semantic, and structured: rewriting strategies for different retrieval backends
  • Keep the original question and the rewritten version: observability and audit requirements
  • Do not change user intent: the core boundary of rewriting quality

Andy Ren Xu's judgment

The practical value of this concept is that it helps you break "AI features that look smart" into deliverable, verifiable, and governable units of work.

query expansionHyDE
京ICP备2026014272号