# Query Rewriting

> A vague question is made clear first. Then the search runs.

**Field:** Artificial Intelligence  
**Category:** Retrieval & Search  
**Also known as:** Query Transformation, Query Expansion (RAG), Query Reformulation

## Think of it like

It is like a helper who asks what you mean. Then they look for that.

## Definition

Query rewriting changes a user's question before the search runs. A model turns a short or vague question into a clearer search. It can fill in words from earlier in the chat, like who "he" is. It can split one question into two searches, or add other words for the same idea. The retriever then searches with the better version.

## Example

Lucy asks the help bot "and for kids?" right after a question about ticket prices. The rewrite becomes "ticket prices for children", and the right page comes back.

## Why it matters

People type short, messy questions. A cleaner search finds better chunks.

## Common mistake

Rewriting so much that the meaning changes. Test that rewrites keep what the user asked.

## Three principles

- **Before the search.** Fix the question first.
- **Fill the gaps.** Use the chat so far.
- **Keep the meaning.** Clearer, not different.

## Related terms

- [Retriever (RAG)](https://learn.benibix.com/term/ai/retriever)
- [Retrieval-Augmented Generation (RAG)](https://learn.benibix.com/term/ai/retrieval-augmented-generation)
- [Multi-Turn Conversation](https://learn.benibix.com/term/ai/multi-turn-conversation)
- [Agentic RAG](https://learn.benibix.com/term/ai/agentic-rag)
- [Hybrid Search](https://learn.benibix.com/term/ai/hybrid-search)

![Left, the knowledge base is prepared ahead: files are parsed to clean text, cut into chunks and indexed. Right, a question is rewritten, then the retriever searches the index and passes the top k chunks to the model, which writes the answer.](https://learn.benibix.com/diagrams/ai3-rag-pipeline.svg)

---

Source: https://learn.benibix.com/term/ai/query-rewriting
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-18
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
