Query expansion
Query expansion is an information-retrieval technique that adds related terms, variants, or reformulations to a query to improve retrieval.
AI-Powered Search
Query expansion is a retrieval technique that augments a query with additional terms or representations to improve matching with relevant content.
- How it is used
- Uses expansion to improve semantic matching and ranking when indexed documents use terms beyond a user's query.
- How deep it goes
- Works through graph traversal, term weighting, and request strategies, then compares graph-based expansion with model-generated sparse tokens.
- Examples
- Uses weighted medicine terms, a fictional-metal query, contextual senses of “server,” and SPLADE++ food queries.
- What you can do after
- Apply it via semantic knowledge graph traversal or SPLADE++ and configure expanded matching or ranking boosts.
LLM Evaluation and Alignment, The Foundational Ideas
Query expansion is a retrieval technique that augments a search query with additional terms or related expressions to improve matching.
- How it is used
- Improves retrieval recall when query vocabulary differs from relevant documents, especially in BM25 or pattern-matching systems.
- How deep it goes
- Adds synonym terms or relaxes regex matching at the application layer, without changing the retrieval system.
- Examples
- Contrasts “authentication failure” with “login rejection” and adds synonym terms or relaxes regex patterns.
- What you can do after
- Diagnose/debug with it by identifying lexical mismatch behind low context recall and augmenting queries with synonyms or relaxed regex patterns.
Read how LLM Evaluation and Alignment, The Foundational Ideas explains query expansion →
Retrieval Augmented Generation, The Foundational Ideas
Query expansion generates alternative query terms or formulations to improve the recall of relevant information.
- How it is used
- Broadens RAG retrieval when one query misses relevant documents because it incompletely expresses the user’s intent.
- How deep it goes
- Traces query variants through parallel retrieval and rank fusion, then illustrates the flow with placeholder Python functions.
- Examples
- Uses student-laptop searches for durability, weight, budget and battery life, plus simulated ranked document lists.
- What you can do after
- Build it from scratch as a toy Python multi-query retrieval pipeline, or apply it with LlamaIndex’s fusion retriever.
Read how Retrieval Augmented Generation, The Foundational Ideas explains query expansion →
The Art of AI Product Development
A retrieval technique that adds terms, variants, or related subqueries to an original search query to improve retrieval results.
- How it is used
- Improves RAG retrieval when users submit vague or poorly structured questions.
- How deep it goes
- Explains rewriting and expansion through concrete subqueries, but stops short of implementation details.
- Examples
- Uses AI-trends questions, SaaS platforms, workflow automation, and classification by technical, market, or integration intent.
- What you can do after
- Apply query expansion to turn broad user questions into targeted retrieval subqueries.
Read how The Art of AI Product Development explains query expansion →
Also covered in
What to know first
- similarity searchSimilarity search is a retrieval technique that finds or ranks items by their similarity to a query, often by comparing feature or vector representations under a similarity or distance measure.
- language modelA language model is a computational model that represents patterns in linguistic sequences to assign probabilities, predict, generate, or evaluate language.
- vector databaseA vector database is a data-management system that stores and indexes numerical vector representations and supports retrieval through similarity or distance searches.
- BM25BM25 is a probabilistic information-retrieval ranking function that scores documents for a query using term frequency, inverse document frequency, and document-length normalization.
Related concepts
- knowledge graphused by · A knowledge graph is a graph-structured representation of entities and their semantically meaningful relationships, often including associated attributes or facts.
- query transformationused by · Query transformation is the modification or reformulation of a search query to improve its match with a retrieval system’s terminology or representation.
- recallmeasures · Recall is the proportion of all relevant or actual positive items that a system successfully retrieves or correctly identifies.
- planningalternative to · Planning is the process of determining and organizing intended actions or steps toward a goal, often accounting for conditions or constraints.
- retrieval-augmented generationproduced by · Retrieval-augmented generation is a technique that retrieves relevant information from external sources and supplies it as context to a generative model when producing an output.
- similarity searchused by · Similarity search is a retrieval technique that finds or ranks items by their similarity to a query, often by comparing feature or vector representations under a similarity or distance measure.
Questions about query expansion
What is query expansion?
Query expansion is an information-retrieval technique that adds related terms, variants, or reformulations to a query to improve retrieval.
Which Manning books explain query expansion?
AI-Powered Search, LLM Evaluation and Alignment, The Foundational Ideas, Retrieval Augmented Generation, The Foundational Ideas and The Art of AI Product Development.
What should I know before learning query expansion?
Manning books that teach query expansion usually introduce similarity search, language model, vector database and BM25 first.
What is the difference between query expansion and planning?
Query expansion is an information-retrieval technique that adds related terms, variants, or reformulations to a query to improve retrieval. Planning is the process of determining and organizing intended actions or steps toward a goal, often accounting for conditions or constraints.
What is query expansion also called?
Query expansion is also called query augmentation.
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.



