Bank of Georgia public sites · site search, 4 min read
Trie-based search engine
Built bilingual full-text search and autocomplete for three public sites as one Node service with a hand-built character trie. Prefix lookup matches inflected Georgian nouns, and query-time transliteration lets Georgian typed in Latin letters find the same pages.
The problem
Three public properties needed search in Georgian and English. Georgian nouns inflect, so the word a user types is rarely the exact form on the page, and Georgian speakers often type phonetically on a Latin keyboard. Exact token matching misses most of those queries.
The approach
The service reads each site through its sitemap, extracts the text, builds a trie per channel and language, and answers queries from memory.
daily schedule ───▶ worker threads: sitemap → pages → text
│
▼
one trie per channel and language
│ merged on each run
▼
search query ───▶ read-only search service ───▶ ranked resultsKey decisions
Why a trie
Georgian nouns inflect at the end of the word, so a prefix lookup handles them naturally: სესხ reaches სესხი, სესხის and სესხები in one walk. It also avoids operating a separate search cluster.
type TrieNode = {
children: Map<string, TrieNode>;
pages: Map<PageId, Hit>; // pages whose word ends here
};
/** Every page under a prefix: სესხ reaches სესხი, სესხის, სესხები */
function collect(root: TrieNode, prefix: string) {
let node: TrieNode | undefined = root;
for (const char of prefix) {
node = node.children.get(char);
if (!node) return new Map<PageId, Hit>();
}
const hits = new Map<PageId, Hit>();
const stack = [node];
while (stack.length) {
const next = stack.pop()!;
next.pages.forEach((hit, id) => addHit(hits, id, hit));
next.children.forEach((child) => stack.push(child));
}
return hits;
}Expanding the query at read time
Each query is walked as typed, transliterated (Latin sesxi becomes სესხი) and with synonyms substituted. Synonyms are prefix pairs such as credit and loan, so editing them is a config change with no reindex.
Ranking results
Every page a query reaches gets an ordering score, and the AI summary card uses the same score to pick its sources, so this ordering decides what the model reads.
- A title match outweighs a body match: 3 points against 1.
- An exact word outweighs a prefix: an exact hit scores 1.5× its prefix value.
- A match through a synonym or transliteration scores 0.8× the as-typed match, so the user's own words win ties.
- Scores add up across query terms, so a page matching every term rises above one that matches a single term many times.
Separating crawling from serving
Indexing runs on worker threads, and the HTTP layer only reads. A completed run replaces only the indexes it rebuilt, so a channel that fails to crawl keeps serving its previous index. Unchanged pages are reused based on the sitemap's lastmod.
Impact
- Bilingual search for three public sites answers at a 12 ms p95 from one service, with no separate search infrastructure to provision or tune.
MeasuredA Prometheus histogram around the search handler, read in Grafana over seven days of production traffic. Server time only, network excluded.
- About 4,200 pages are indexed across 3 sites and 2 languages.
MeasuredThe document count each indexing run logs when it finishes, summed over the six channel-and-language indexes.
- All the indexes take about 180 MB of memory per instance.
MeasuredHeap used after the indexes load, from
process.memoryUsage(), minus the heap of the same process started with empty indexes. - A full reindex takes about six minutes; the daily run, which reuses unchanged pages, takes under one.
MeasuredRun durations from the indexer's logs: the median of 30 daily runs and of 5 forced full rebuilds.
- Georgian typed in Georgian or phonetically in Latin finds the same pages, as do inflected nouns and synonyms like credit and loan.
- Adding a channel is a config entry plus a parser method.
Trade-offs
What it cost
- Every index lives in memory in every instance, so memory grows with the corpus.
- Results can be up to a day stale, because indexing runs on a daily schedule.
- No typo tolerance or understanding of phrases. That gap is what the LLM layer later filled.
What I’d change
- Persist a snapshot of each trie, so a restarted instance serves at once instead of waiting for a crawl.
- Reindex a page when the CMS publishes it, instead of once a day.
Connected work
These case studies are parts of one platform. This one connects to: