There is no best retrieval method, only one that fits the shape of the data (unstructured prose, semi-structured documents, tables, code or logs) and the pattern of the query (a fuzzy concept, an exact identifier, an aggregate over rows, a multi-hop question, a conversational follow-up). Scenario questions in this area describe a data shape and a failing query type and ask you to pick the method that fits, or to spot the method that cannot possibly work. Chunking and indexing are Lesson 1.5; this lesson is about choosing how to search once the index exists.
The toolbox and where each tool breaks
| Strategy | Strength | Typical failure |
|---|---|---|
| Semantic (dense embeddings) | Paraphrases and concepts | Exact identifiers, rare tokens, part numbers, sometimes negation and numbers |
| Keyword (BM25) | Exact terms: error codes, names, SKUs | Synonyms and paraphrase; the user's words differ from the document's |
| Hybrid (both, merged by rank fusion) | Covers concept and exact-match queries | Two indexes to run; fusion and weights to tune |
| Reranking | Re-scores a wide candidate set against the query for better top-k precision | Cannot surface documents that were never in the candidate set; adds a model call |
| Metadata filtering | Narrows by tenant, date, type or entitlement | Only as good as the metadata; wrong filters silently hide the answer |
| Structured or SQL retrieval | Filters, joins and aggregates over tables | Wrong or unsafe queries; needs schema context and safeguards |
| Query rewriting or decomposition | Turns follow-ups into standalone queries; splits multi-part questions | Extra call; the rewrite can drift from the user's intent |
| Agentic retrieval | The model searches iteratively and follows references | More turns, tokens and latency; depends on good search tools |
Anthropic's Contextual Retrieval experiments illustrate the layering: combining contextual embeddings with contextual BM25 through rank fusion cut the top-20 retrieval failure rate further than embeddings alone (5.7% to 3.7% to 2.9%), and adding a reranker over a wider candidate set (150 narrowed to 20) reached 1.9%. Those are numbers from their datasets, and the lesson is the pattern, not the digits: each stage fixes a different failure, and each adds cost.
Matching strategy to data shape and query pattern
| Data and query | Fit | Why |
|---|---|---|
| Prose knowledge base, conceptual questions | Dense retrieval, plus a reranker if top-k precision is weak | Meaning matters more than exact wording |
| Prose that queries reference by code, ID or product name | Hybrid | Dense vectors are unreliable on rare exact tokens; BM25 is strong there |
| Orders, metrics or events in tables; "how many", "total", "top 5" | Structured query (parameterised SQL or a fixed set of query tools) | Similarity search cannot count or sum; embedding a table does not make it computable |
| Large, fast-changing codebase or log store; exploratory questions | Agentic search (grep and glob style tools), possibly with an index | No index staleness; the model can follow references |
| Multi-hop questions across documents | Query decomposition or agentic retrieval | The second lookup depends on the first result |
| Chat follow-ups such as "and for contractors?" | Rewrite with history into a standalone query | The raw follow-up has no searchable content |
| Multi-tenant or permissioned data | Mandatory metadata pre-filter | Access must be enforced before content reaches the model |
Key concept: match the method to the shape of the answer
Ask what the answer looks like. A passage that means the same thing as the question wants semantic search. A row that contains a specific token wants keyword search. A number computed over many rows wants a query engine. A chain of dependent lookups wants an agent or a decomposition. Popularity of a technique is not evidence.
Agentic retrieval and structured data
Agentic retrieval lets Claude decide what to search for, inspect results, and search again. Anthropic's context engineering write-up describes the hybrid used by Claude Code: some context (project instructions) loaded up front, and the rest explored just in time with tools such as grep and glob, keeping lightweight identifiers rather than pre-loading content. It states the cost plainly: runtime exploration is slower than retrieving pre-computed data, and it needs careful tool design. Tool results can carry search_result blocks so the model's citations point at your sources (Lesson 1.5).
Structured retrieval needs different safeguards. Exposing free-form SQL to the model widens the blast radius (Lesson 1.1), so prefer parameterised query tools or a constrained query builder, run them on a read-only credential, expose the schema as context, cap result sizes and validate generated queries. Aggregates should come from the database, not from the model summing rows it was shown.
Cost, evaluation and safety
- Each stage adds latency. A reranker is a model call, query rewriting is a model call, and each agentic search is a turn. Treat depth (how many candidates, how many searches) as a swept variable, as in Lesson 1.3.
- Evaluate by query type. Overall recall hides that exact-ID queries fail while concept queries succeed. Tag each test query with its pattern, and measure candidate recall (is the gold item in the wide set?) separately from top-k precision (is it near the top?). Recall problems need a different retriever or query; precision problems need reranking.
- Retrieved text is untrusted input. A document can contain instructions aimed at the model. Enforce access control by filtering at retrieval time using the user's entitlements, not by asking the model to ignore documents it should not see (Lesson 1.2), and log queries and results without their content by default (Lesson 1.4).
Common exam distractor
"Use vector search for everything" fails on identifiers and aggregates. "Add a reranker" is the wrong fix when the gold document is not in the candidate set, because a reranker only reorders what was retrieved. "Embed the whole orders table so the model can answer totals" asks similarity to do arithmetic. And "always retrieve more chunks" trades tokens and latency for a recall gain you should have measured first.