Search Indexing And Autocomplete For Instruments And News
Asked of: Software Engineer
Last updated

What's being tested
This topic tests whether you can design a low-latency, high-availability search path over two very different datasets: structured financial instruments and rapidly changing news. The interviewer is probing your command of inverted indexes, prefix-search data structures, partitioning, caching, freshness, and graceful degradation—not merely whether you can name Elasticsearch. Bloomberg cares because a trader or terminal user expects a correct result in milliseconds, even during market spikes, while identifiers, aliases, entitlements, and news relevance are changing continuously.
Core knowledge
-
An inverted index maps normalized terms to document identifiers, commonly storing postings lists with fields, positions, timestamps, and scores. It supports token search efficiently, but plain term indexes do not directly solve prefix completion.
-
Autocomplete is usually implemented with a trie, compressed radix tree, or finite-state transducer such as
FST. A trie gives prefix lookup for prefix length , while storing top- completions at each node trades memory for predictable latency. -
Instrument search needs multiple fields: ticker,
ISIN,CUSIP, exchange symbol, issuer name, product type, and aliases. Keep exact identifiers, normalized text, and display labels separate soIBM,US4592001014, and “International Business Machines” can rank appropriately. -
Normalize before indexing: Unicode case folding, punctuation handling, whitespace collapsing, transliteration where appropriate, and exchange-specific symbol rules. Preserve the original string for display; otherwise a canonicalization step can make results impossible to explain.
-
News search typically combines token retrieval with time decay and field boosts. A simple score might be ; keep ranking deterministic with a stable document ID tie-breaker.
-
Partitioning should support the dominant query path. Shard instrument documents by stable instrument ID or hash for balanced writes, while news may use time-based segments plus a routing strategy; avoid a design that requires querying every shard for every keystroke.
-
Use immutable index segments and background merges, as in
Lucene, to make reads lock-light. New documents can enter a small mutable or near-real-time segment, then merge asynchronously; expose the resulting freshness bound explicitly. -
Treat indexing as at-least-once and make updates idempotent using a stable document or instrument version. Tombstones, version checks, and replayable change events prevent stale updates from overwriting newer data.
-
A serving API should enforce bounded work: minimum prefix length, maximum result count, request deadlines, cancellation, and pagination or continuation tokens. Return structured results containing ID, display label, type, exchange, timestamp, and entitlement metadata.
-
Cache hot prefixes and common exact queries at the edge or service tier. Use short TTLs for news, longer TTLs for relatively stable instrument metadata, and include locale, entitlement context, and index version in the cache key.
-
Consistency is usually deliberately mixed: instrument identity and entitlement changes need stronger correctness, while news ranking can tolerate eventual freshness. If an index is stale, return a safe older result or fail over to a previous snapshot rather than serving partial corrupt state.
-
Measure
p50,p95, andp99latency separately for cache hits, cold prefixes, and fan-out searches; also track zero-result rate, stale-index age, correction rate, and availability. Log query normalization, selected shard, index version, and result reason without leaking restricted content.
Worked example
Representative prompt: “Design Search Indexing and Autocomplete for Instruments and News.” In the first 30 seconds, clarify whether the API must support prefix completion, full-text search, or both; ask for expected QPS, latency target, update rate, languages, entitlement rules, and acceptable freshness. State an assumption such as 100,000 autocomplete requests per second globally, p99 below 100 ms, near-real-time news, and strongly correct instrument identifiers. Organize the answer around the data model and normalization pipeline, index structures and shard layout, query serving and ranking, and reliability plus observability. Use a compressed trie or FST for instrument prefixes and a Lucene-style inverted index for news, with separate serving paths because their update and ranking characteristics differ. Explicitly flag the tradeoff between storing top completions at every prefix node for low latency and storing less metadata to reduce memory and rebuild cost. Explain versioned immutable snapshots, idempotent updates, cache keys, deadlines, and a fallback to the last known-good index. Close by saying that, with more time, you would validate shard fan-out under realistic symbol distributions and test entitlement changes, corrections, and regional failover.
A second angle
Representative prompt: “How would you support typo-tolerant autocomplete for security names without harming ticker accuracy?” The framing changes from broad architecture to query interpretation and bounded algorithmic cost. Use exact and prefix matches first, then apply bounded edit distance, character n-grams, or phonetic alternatives only when the high-confidence path returns too few results. Do not apply fuzzy matching equally to identifiers such as ISIN, where one-character substitutions can produce a different valid instrument. Measure false-positive selection risk separately from ordinary zero-result rate, and make the fallback behavior explainable.
Common pitfalls
Pitfall: Analytical mistake: Saying “put everything in
Elasticsearch” without separating instrument identity from news retrieval ignores different freshness, ranking, and correctness requirements. A stronger answer names the index structures, update semantics, shard strategy, and query path that the chosen engine provides.
Pitfall: Communication mistake: Jumping into trie implementation before asking about latency, QPS, update rate, and entitlements makes the design appear arbitrary. State assumptions early, then tie every major choice back to one of them.
Pitfall: Depth mistake: Claiming that a cache solves performance without discussing invalidation, authorization context, or hot-prefix skew is incomplete. Explain TTLs, cache-key isolation, versioning, and what happens when the index or cache is stale.
Connections
An interviewer may pivot to distributed caching, event-driven indexing, consistent hashing, rate limiting, or authorization-aware data access. They may also ask about Lucene segment merges, zero-downtime index rebuilds, multi-region failover, or designing a top- data structure for prefix results.