Layer 3 · Go deeper · 9 min
Go deeper
Size it, build it, then make the calls an interviewer will push you on.
Back of the envelope
Size it up
Tap through each step of the arithmetic.
For “cotton kurta”, does a short title or a long description rank higher?
How many primary shards does a 600 GB index need?
Build-up · 6 steps
Follow one query through the index
From a raw product title to a ranked top k, the path every full-text query takes.
Step 1 of 6
Analyse the document
Character filters strip the HTML, the tokenizer splits words and records positions, and token filters lowercase, stem, drop the stop word “for” and add the synonym tunic.
4 interview moments
You’re the candidate
The interviewer pushes on the hard parts. Pick an approach and see how it holds up.
Deep dive 1 of 4
Interviewer
“Products live in Postgres and search runs on Elasticsearch. How do you keep the index in step with the database?”
Your move. Pick an approach:
Deep dive 2 of 4
Interviewer
“Your team wants search over the help articles in its admin console. Do you stand up Elasticsearch?”
Your move. Pick an approach:
Deep dive 3 of 4
Interviewer
“Search quality needs a different analyzer on the live products index. How do you roll it out?”
Your move. Pick an approach:
Deep dive 4 of 4
Interviewer
“Bots and keen shoppers page deep into results on a 5-shard index. How do you serve page after page?”
Your move. Pick an approach:
Build-up · 5 steps
Follow one write into a shard
Searchable and durable are different events. Watch a new product become both, then see how deletes and merges keep the index lean.
Step 1 of 5
Index
The document is analysed into an in-memory buffer and appended to the translog. By default the translog is fsynced on the primary and every replica before the client gets its ack.