QueryExpander vs. raw query retrieval

Context

QueryExpander uses Claude Haiku to rewrite a single query into 3–5 alternative phrasings before retrieval. It targets the core recall problem in documentation search: a user's wording rarely matches the exact terms in the indexed documents. By exposing synonyms, feature names, tool categories, and developer jargon, the expander increases the chance that at least one phrasing overlaps with the target content.

Expansion is opt-in and fail-safe. If the Claude API call fails, retrieval continues with the original query unchanged.

Feature comparison

Capability Raw query retrieval QueryExpander
Query variants sent to retrieval 1 3–5
Handles vocabulary mismatch No Yes — generates synonyms and developer jargon
LLM dependency None Claude Haiku (claude-haiku-4-5-20251001)
Latency added None One Haiku API call per query
Response caching N/A Yes (cache=True by default)
Async support Depends on retriever Yes — expand_async()
API failure behavior N/A Falls back to original query automatically
Output format JSON array of strings

Tradeoffs

Where QueryExpander wins

Where raw retrieval wins

Use QueryExpander when…

Stick with raw query retrieval when…

Source files

Tags: expander, hybrid-retrieval, recall, claude, haiku