liveBook · Manning

Query rewriting

Query rewriting is the transformation of a query into an alternative formulation intended to better support its execution or retrieval while preserving its intended meaning or behavior.

How 5 Manning books explain it

AI Agents and Applications

Query rewriting is a technique that transforms an original search request into one or more clearer or more targeted queries to improve retrieval results.

How it is used
Improves web-search and RAG retrieval by turning unclear requests into search queries before results reach answer synthesis.
How deep it goes
Builds a prompt-to-LLM rewriter and a complete RAG chain, then extends generation to multiple parsed queries and retrieval.
Examples
Uses basketball-championship web searches and Cornwall travel questions retrieved from a vector store.
What you can do after
Build it from scratch with a LangChain rewriter chain, or apply MultiQueryRetriever to retrieve across alternative questions.

Read how AI Agents and Applications explains query rewriting →

AI-Powered Search

Query rewriting is the transformation of an original search query into an alternative query that preserves or enhances its intended retrieval behavior.

How it is used
Improves search recall, precision, and ranking by transforming parsed and enriched user queries before execution.
How deep it goes
Explains expansion, minimum matching, boosting, and engine translation, but stops short of evaluating rewrite quality.
Examples
Uses “vibranium” expansion, relatedness weights, minimum-match thresholds, boosts, and Solr query-tree transformations.
What you can do after
Builds rewritten search requests with related terms, matching constraints, ranking boosts, and engine-specific syntax.

Read how AI-Powered Search explains query rewriting →

Essential GraphRAG

Query rewriting is the transformation of a user query into a formulation that better matches the language and context of target documents.

How it is used
Improves RAG retrieval accuracy and recall when query wording fails to match relevant document language.
How deep it goes
Explains the terminology gap, names major strategies, and extends matching to summaries, paraphrases, and hypothetical questions.
Examples
Uses hypothetical document retrieval, step-back prompting, contextual summaries, paraphrases, and hypothetical question embeddings.
What you can do after
Apply it via hypothetical document retrieval or step-back prompting to improve document matching and retrieved-answer relevance.

Read how Essential GraphRAG explains query rewriting →

The Art of AI Product Development

A retrieval technique that rewrites an input query into a form better suited to searching a target information collection.

How it is used
Improves retrieval precision when users submit vague or poorly structured questions to a retrieval-augmented generation system.
How deep it goes
Demonstrates rewriting, expansion, and classification through product examples without detailing implementation internals.
Examples
Uses broad AI-trend questions, SaaS and workflow-automation subqueries, and irrelevant healthcare or finance results.
What you can do after
Apply it by converting broad questions into focused subqueries and routing them toward relevant sources.

Read how The Art of AI Product Development explains query rewriting →

Grokking AI Applications

A technique that rephrases a user query to improve its semantic match with retrievable document content.

How it is used
Improves retrieval in RAG pipelines when users’ wording does not align with document phrasing.
How deep it goes
Explains the rationale, HyDE variant, translation use, and Langflow placement without detailing prompt design or evaluation.
Examples
Uses a thirsty-customer menu question, hypothetical answers, and English-to-Spanish query translation.
What you can do after
Apply it via Langflow by placing a Prompt Template and LLM between Chat Input and ChromaDB.

Read how Grokking AI Applications explains query rewriting →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.