ElasticSearch ElasticSearch 3 — Questions and Answers
Question 1: Which Elasticsearch component is responsible for routing documents to the correct primary shard?
- The coordinating node using a hash of the document ID (Correct answer)
- The master node based on cluster state
- The data node with the lowest disk usage
- The ingest node after pipeline processing
Correct answer: The coordinating node using a hash of the document ID
By default, Elasticsearch routes documents to shards using a hash of the document ID modulo the number of primary shards.
Question 2: What is a 'near real-time' (NRT) search in Elasticsearch?
- Search that returns results within 1 millisecond
- Search that becomes available within ~1 second after indexing due to refresh intervals (Correct answer)
- Search performed only on primary shards
- Search using caching to avoid re-scanning indices
Correct answer: Search that becomes available within ~1 second after indexing due to refresh intervals
Elasticsearch is near real-time because indexed documents become searchable only after a refresh (default every 1 second), not immediately.
Question 3: In Elasticsearch, what does the `must_not` clause in a bool query do?
- Requires all listed queries to match
- Boosts scores for matching documents
- Excludes documents that match any of the listed queries (Correct answer)
- Makes matching optional but score-contributing
Correct answer: Excludes documents that match any of the listed queries
The must_not clause excludes documents that match any of its queries, and matching documents contribute a score of 0.
Question 4: What is the role of a 'master-eligible' node in an Elasticsearch cluster?
- To handle all search requests from clients
- To store all primary and replica shards
- To participate in master election and manage cluster state (Correct answer)
- To preprocess documents before indexing
Correct answer: To participate in master election and manage cluster state
Master-eligible nodes can be elected as the cluster master, which manages cluster-wide settings, shard allocation, and node membership.
Question 5: Which Elasticsearch API is used to retrieve the mapping of an index?
- GET /<index>/_settings
- GET /<index>/_mapping (Correct answer)
- GET /<index>/_schema
- GET /<index>/_fields
Correct answer: GET /<index>/_mapping
The GET `/<index>/_mapping` API returns the field mappings defined for the specified index.
Question 6: What happens when you send a document to Elasticsearch with an ID that already exists using a PUT request to `/<index>/_doc/<id>`?
- The request is rejected with a 409 conflict error
- The existing document is deleted and replaced with the new one (Correct answer)
- The new fields are merged into the existing document
- The operation is queued until the existing document is refreshed
Correct answer: The existing document is deleted and replaced with the new one
A PUT to `/<index>/_doc/<id>` performs an index operation that fully replaces the existing document, incrementing its version number.
Question 7: Which analysis component in Elasticsearch is responsible for breaking text into individual tokens?
- Character filter
- Token filter
- Tokenizer (Correct answer)
- Normalizer
Correct answer: Tokenizer
The tokenizer receives a stream of characters and breaks it into individual tokens (usually words), which are then passed to token filters.
Which Elasticsearch component is responsible for routing documents to the correct primary shard?