Elasticsearch medium
A developer provides a custom `routing` parameter (e.g., `routing=user_123`) when indexing documents. What is the query-time performance benefit?
- A It allows the query to bypass the Master node entirely.
- B Shard Targeting: It ensures all documents for that user reside on the *same physical shard*. A search can then target just that one shard instead of broadcasting across the entire index, significantly reducing the 'Scatter-Gather' overhead.
- C It automatically prioritizes the document in the cache using a Most-Recently-Used algorithm.
- D It allows the indexing of duplicate IDs without causing a conflict.
Answer: B. Shard Targeting: It ensures all documents for that user reside on the *same physical shard*. A search can then target just that one shard instead of broadcasting across the entire index, significantly reducing the 'Scatter-Gather' overhead.
In a 100-shard index, a standard query hits 100 shards. With custom routing, you hunt in exactly one shard. This is critical for massive multi-tenant systems where you want tenant-specific queries to be as light as a single Get-by-ID.
One system design question a day, with spaced repetition so the ones you miss come back.
Get the appRelated questions
- What are the two primary reasons for configuring one or more 'Replica Shards' for an index?
- When a String field is mapped as `text`, what process is performed to enable full-text search capability?
- What is the primary benefit of splitting an Elasticsearch index into multiple 'Primary Shards'?
- Every document stored in an Elasticsearch index is uniquely tracked by which mandatory metadata field?
- Elasticsearch search results include a metadata field called `_score`. What does this value primarily indicate?
- What is the primary architectural purpose of Elasticsearch in a modern software stack?