Skip to main content
Follow-ups like “what about the second one?” are clear to a person but weak as vector-search queries. Query rewriting uses an LLM plus optional context to produce a standalone search_query before embedding and retrieval. Use rewriting for multi-turn search and chat. Skip it for one-shot, self-contained queries because it adds an LLM call.

Retrieval rewriting

result.search_query shows what was embedded and searched. If rewriting fails, retrieval falls back to the original query and returns a retryable rewrite error.

Query pipeline rewriting

Chat rewriting

Chat rewriting uses QueryRewriteConfig. If you do not pass a separate rewrite LLM, chat falls back to the chat LLM. Use Streaming when you want to see the rewritten search_query in progress events.

When to use it

Use a small, inexpensive LLM for rewriting. Rewriting is short, structured, and usually does not need the same model as final answer generation.