Read path:
- Client sends a query; the gateway authenticates and rate limits.
- Cache check - popular queries are heavily repeated, so a cache on the normalised query string often serves 30-50% of traffic outright.
- Query understanding - tokenise, lowercase, stem, remove stop words, apply spell correction and synonyms.
- Scatter phase - the query is broadcast to every shard in parallel, because the inverted index is partitioned by document. Each shard returns its own top N.
- Gather phase - the coordinator merges the per-shard results and re-ranks globally to produce the final top N.
- Hydrate - fetch titles, snippets and images for just those N results from the document store.
- Return, and log the query for ranking feedback.
The key insight to voice: this is a scatter-gather fan-out, so it suffers tail latency amplification - the query is only as fast as the slowest shard. Mitigate with hedged requests to replica shards and a timeout that returns partial results rather than waiting.
Write path is separate and asynchronous: a document update publishes an event, an indexing worker updates the inverted index, and the new document becomes searchable seconds later. Near-real-time indexing is the norm, and stating that search is eventually consistent is exactly the right call.