RAG & Retrieval · Ground answers in evidence

When should you rewrite the user's query?

Mediumquery rewritingretrievalconversationUpdated Oct 2026
Quiz this track

Short answer

Rewrite when the query is ambiguous, conversational or depends on prior turns. Resolve references, expand acronyms and add context, but preserve the user's actual intent and keep the original for fallback.

Users rarely write ideal search queries. A follow-up like 'what about the enterprise plan?' has no meaning without the previous turn. Rewriting turns it into a standalone retrieval query. It can also normalise spelling, expand acronyms and add synonyms.

  • Resolve pronouns and ellipsis using recent conversation context.
  • Expand internal acronyms and product names with a controlled dictionary.
  • Generate multiple query variants for recall, then fuse the results.
  • Keep the original query and log rewrites so regressions are debuggable.
Rewriting can drift from intent, especially with vague prompts. Do not rewrite when the original is already a precise identifier.

Follow-ups you should expect

Interviewers use these to check whether the first answer was understanding or memorisation.

  1. 1How would you evaluate a query rewriter?
  2. 2When would rewriting hurt retrieval?
  3. 3How many variants would you generate, and why?

Say it in the interview

I rewrite when the query will not retrieve well on its own, usually because it refers to earlier turns or uses internal shorthand. The rewrite resolves references and expands terms, and I keep the original so I can compare results. I do not rewrite precise identifiers, because a model can easily drift from the intent. I evaluate the rewriter by whether retrieval recall improves, not by whether the rewritten query looks sensible.

Use this as a model, not a script. Saying it in your own words is what makes it survive follow-up pressure.

Related questions

Reading is step one

Now say it out loud.

Understanding an answer and delivering it under pressure are different skills. Rehearse this topic in a live RAG & Retrieval mock interview and get scored feedback on depth, clarity and confidence.