🔎 Search with Elasticsearch — interview questions
11 questions. Filter by what the role asks for; open one for the six layers of the answer. The course is where the answers come from.
11 of 11
01A `Product` index has a `status` field with no explicit mapping. Dynamic mapping gave it `text` (with a `keyword` sub-field, as it does for every string). A query `{ "term": { "status": "PAID" } }` returns nothing, even though documents with `status: "PAID"` clearly exist. Why, and what's the fix?Mappingseasy0-2y02`WHERE title LIKE '%kafka%'` scans every row. A search engine answers the same kind of query in milliseconds over millions of documents. What structural difference makes that possible, and what's the cost paid for it?Inverted index fundamentalseasy0-2y03A custom analyser is defined with token filters in the order `["stemmer", "lowercase", "stop"]`. A document containing "The Consumers Are Running" is indexed through it, and later a lowercase query for "consumers running" fails to match. Trace the chain and explain why.Analysis internalsmedium3-5y04A search team wants to try 'better normalization' and proposes swapping the English stemmer for a lemmatizer, expecting mostly the same results with cleaner output. What's actually different about what each one does to a word, and what would change?Analysis internalsmedium3-5y05Two documents both mention `kafka`: one five times, one fifty times. Under BM25's default `k1 = 1.2`, would the fifty-mention document score roughly ten times higher on that term? Walk through why or why not.Relevance and BM25medium3-5y06Work through the lesson's own comparison: document A is 50 words (corpus average 200) and mentions `kafka` twice; document B is 800 words and mentions `kafka` six times. With `k1 = 1.2`, `b = 0.75`, which scores higher on that term, and why does the shorter document win despite fewer mentions?Relevance and BM25hard5-8y07A product search puts `{ "term": { "status": "PUBLISHED" } }` inside a `bool` query's `must` clause alongside the user's search text. What's wasted by doing that, and what's the fix?Query DSLmedium3-5y08A `bool` query's `filter` array has `{ "term": { "title": "Kafka" } }`, where `title` is mapped as `text` with the standard analyser. It matches nothing, even for documents whose title is literally "Kafka". Diagnose it, and name the two different fixes depending on what the query actually needs to do.Query DSLmedium3-5y09A team wants to add primary shards to an existing, growing index without reindexing, expecting it to rebalance data across the new shards the way adding a database read replica doesn't require touching existing data. Why doesn't this work, and what's the actual mechanism that makes the primary shard count permanent?Cluster operationshard5-8y10A checkout flow writes an order update, gets a `200` response from Elasticsearch, and immediately runs a search that's supposed to include it. The search doesn't find the just-written document. The write response says success and the cluster is green. What actually happened, and what's the one-line fix for this specific request?Cluster internalssenior8+y11A nightly job bulk-indexes two million product documents one document at a time, and search latency on the same cluster degrades badly during the job, with some writes returning `429`. What's actually competing for resources, and what three changes would you make to the job itself?Cluster operationshard5-8y