Bank of Georgia public site, 4 min read
LLM-assisted search API
Added an LLM layer in front of the existing keyword index so questions and typos resolve to indexed terms, plus a summary card built from the most relevant result pages. Model calls fall back to the raw query, so search keeps working through a provider outage.
The problem
The keyword index worked when people typed a product name and rarely gave them what they wanted otherwise. Real queries are phrases (what do I need for a car loan) and typos, in two languages.
The approach
An LLM rewrites the query into an indexed term before it reaches the index, and a summary card sits above the results. The card is retrieval-augmented generation (RAG) with the keyword index as the retriever: the ordering score returned for each result picks the most relevant pages, and the model summarizes them. The keyword index and autocomplete both run on the trie-based search service.
query ───▶ rewrite (LLM) ───▶ keyword index ───▶ ranked results
│ │
├─ single token → spelling correction │
└─ phrase → keyword extraction │
▼
most relevant pages ──▶ LLM ──▶ summary cardKey decisions
Separate prompts for typos and phrases
Fixing a typo and extracting intent from a sentence are different jobs. A simple check on the query's shape picks the prompt without a model call: a phrase is reduced to one indexed term, and a single word gets its spelling fixed.
| Query | Kind | Rewritten to |
|---|---|---|
იპოტეკა | Typo | იპოთეკა |
კალკულიატორი | Typo | კალკულატორი |
როგორ ავიღო ავტო სესხი | Phrase | ავტო სესხი |
ბარათი დავკარგე | Phrase | ბარათის დაბლოკვა |
morgage | Typo | mortgage |
what do I need for a car loan | Phrase | car loan |
const isPhrase = (query: string) =>
query.trim().split(/\s+/).length > 1;
export async function rewrite(query: string, lang: Lang) {
const prompt = isPhrase(query)
? extractKeyword(query, lang)
: fixSpelling(query, lang);
try {
const term = await withTimeout(model.generate(prompt), 800);
return term.trim() || query;
} catch {
// Provider down or slow: plain keyword search
return query;
}
}Falling back to keyword search
Each model call handles its own errors and returns the raw query, so a provider outage falls back to the pre-AI search. Each call also has an 800 ms budget; past that, the raw query goes through. A failed summary simply doesn't render, and the whole layer sits behind a config flag.
Results first, summary second
The summary runs as a separate request after the results render, filling a skeleton placeholder so nothing jumps. Input is debounced and superseded requests are cancelled. One base Lit element, shared through Module Federation, powers both the results page and the header search.
Caching summaries by keyword
Summaries are cached in Redis by language and keyword, so different phrasings of the same term reuse one summary and model costs stay low.
Keeping the summary grounded
The prompt gets only the text of the top three pages and is told to answer from them alone. The card links to those pages as its sources, and it doesn't render when fewer than two results clear the score threshold, so a vague query gets results without an invented answer.
Impact
- Clicks on search results rose by about 50%, comparing the two months before launch with the two months after.
MeasuredGA4
select_contentevents fired by result links on the results page and in the header search, with internal traffic filtered out. - Clicks per search went from 0.41 to 0.61, so the rise isn't just more searches. Searches that ended without a click fell from 58% to 39%.
MeasuredThe same click events divided by GA4
view_search_resultsevents. A search counts as clickless when no result click follows it in the same page view. - The rewrite adds about 180 ms at the median and 420 ms at p95 before results load.
MeasuredA timer around each model call, exported as a Prometheus histogram and read in Grafana over 30 days of production traffic.
- 71% of summaries are served from the cache, so most searches never call the model for a summary.
MeasuredHit and miss counters on the summary-cache lookup, exported to Prometheus: hits ÷ (hits + misses) over the same 30 days.
- Questions, phrasings and misspellings now resolve to indexed terms, so people find the content they are looking for more often.
- If the model fails, users get the original keyword search.
Trade-offs
What it cost
- Every rewritten query waits on a model round-trip before results load: about 420 ms at p95.
- The summary is only as good as the index's ordering. When ranking puts a weak page first, the card summarizes a weak page.
- Model output isn't deterministic, so the same query can rewrite differently after a provider update.
What I’d change
- Run the raw query and the rewrite in parallel, and swap results only when the rewrite differs, so the common case pays no latency.
- Build the evaluation set of real queries before launch. I assembled it afterwards, from the logs.
Connected work
These case studies are parts of one platform. This one connects to: