# What is query rewriting in AI search?

> Query rewriting turns a user's prompt into one or more search queries before retrieval. ChatGPT search rewrites questions into targeted queries.

Canonical: https://promptlyfound.com/glossary/query-rewriting
Updated: 2026-12-01

## Short answer

Query rewriting is **turning a user's prompt into one or more search queries before retrieval**. A long, conversational question becomes short queries that a search engine or an index can match. OpenAI says ChatGPT search typically rewrites a question into targeted queries that it sends to search providers. Retrieval then runs on the rewritten queries instead of the original prompt.

## Key findings

- OpenAI gives an example: for a question about drugs that target CCR8 for cancer, ChatGPT might first send a search partner the query 'CCR8 immunotherapy drug development 2025'. [1]
- OpenAI says ChatGPT may use saved memories when it rewrites a search query, and may add a general location based on the user's IP address. [1]
- OpenAI's Retrieval API has a rewrite_query setting. It turns 'I'd like to know the height of the main office building.' into 'primary office building height'. [2]
- 43.04% of the searches named a country or city, 38% included a year and 27% included the year 2026.

Query rewriting is the step between a user's prompt and the search that an AI system runs. The search engine sees the rewritten query, so the pages that come back are the pages that match it.

## How does query rewriting work?

A language model reads the prompt and writes search queries from it. [OpenAI's help page on ChatGPT search](https://help.openai.com/en/articles/9237897-chatgpt-search) gives three examples:[1]

- A researcher asks "what's the latest on the development of drugs that target CCR8 for cancer?" ChatGPT might first search for "CCR8 immunotherapy drug development 2025". After it reviews the results, it may send a more specific query such as "CHS-114 conference 2025".
- A user in the San Francisco area asks for good restaurants near them. ChatGPT may search for "top restaurants San Francisco", using a general location from the IP address.
- With memory turned on, a user who said they are vegan may get the search "good vegan restaurants San Francisco".

Developer tools offer the same step. [OpenAI's retrieval guide](https://developers.openai.com/api/docs/guides/retrieval) has a rewrite_query setting that turns "How do I file a complaint about a service issue?" into "service complaint filing process".[2] Microsoft's guide to [query rewrites in Azure AI Search](https://learn.microsoft.com/en-us/azure/search/semantic-how-to-query-rewrite) can generate up to 10 rewrites per query, in preview, to correct typos and add synonyms.[3]

## What is the difference between query rewriting and query fan-out?

Query rewriting changes how a prompt is worded for search, and query fan-out multiplies the searches. [Google's page on AI features](https://developers.google.com/search/docs/appearance/ai-features) says AI Overviews and AI Mode may issue multiple related searches across subtopics and data sources to develop a response.[4] The guide [What is query fan-out?](https://promptlyfound.com/ai-search/query-fan-out) explains how Google runs these searches.

## How does query rewriting affect which pages AI search finds?

The rewritten query decides which pages a search returns. The paper [Query Rewriting for Retrieval-Augmented Large Language Models](https://arxiv.org/abs/2305.14283) names the reason: there is a gap between the input text and the knowledge that retrieval needs. Its Rewrite-Retrieve-Read framework first prompts a model to write the query, then runs a web search, then lets the model read the results. A small trained rewriter improved results on question answering tasks.[5]

Rewritten queries can add terms such as places and years, as OpenAI's examples show. In our study of 8,430 ChatGPT web searches, 43.04% of the searches named a country or city. [What ChatGPT searches for before it answers](https://promptlyfound.com/research/chatgpt-search-queries) lists the other terms that its queries added, such as years and brand names.

## Sources

1. Searching the web with ChatGPT. OpenAI Help Center. https://help.openai.com/en/articles/9237897-chatgpt-search
2. Retrieval. OpenAI API documentation. https://developers.openai.com/api/docs/guides/retrieval
3. Rewrite queries with semantic ranker in Azure AI Search. Microsoft Learn. https://learn.microsoft.com/en-us/azure/search/semantic-how-to-query-rewrite
4. AI features and your website. Google Search Central, 2025-12-10. https://developers.google.com/search/docs/appearance/ai-features
5. Query Rewriting for Retrieval-Augmented Large Language Models. arXiv, 2023-05-23. https://arxiv.org/abs/2305.14283

---

This is a plain-text copy of https://promptlyfound.com/glossary/query-rewriting from Promptly Found. The web page is the canonical version and includes the charts.
