ElasticSearch ElasticSearch 2 — Questions and Answers
Question 1: What is the default number of primary shards for an index created in Elasticsearch 7.x and later?
- 5
- 3
- 1 (Correct answer)
- 10
Correct answer: 1
Starting with Elasticsearch 7.0, the default number of primary shards per index was changed from 5 to 1.
Question 2: Which Elasticsearch query type is used to find documents where a field value falls within a specified range?
- term query
- match query
- range query (Correct answer)
- exists query
Correct answer: range query
The range query returns documents where a field value falls within a specified range using gte, gt, lte, or lt parameters.
Question 3: What does the `_source` field in an Elasticsearch document contain?
- The index routing key
- The original JSON document as indexed (Correct answer)
- The analyzed tokens for each field
- The document's shard assignment
Correct answer: The original JSON document as indexed
The `_source` field stores the original JSON body of the document as it was passed at index time.
Question 4: Which aggregation type in Elasticsearch computes the average value of a numeric field?
- stats aggregation
- avg aggregation (Correct answer)
- value_count aggregation
- extended_stats aggregation
Correct answer: avg aggregation
The avg aggregation is a single-value metrics aggregation that computes the average of numeric values extracted from the aggregated documents.
Question 5: What is the purpose of the Elasticsearch `alias` feature?
- To create a secondary name pointing to one or more indices (Correct answer)
- To replicate data across clusters
- To define custom analyzers for fields
- To snapshot indices to remote storage
Correct answer: To create a secondary name pointing to one or more indices
An alias is a secondary name for one or more indices, enabling zero-downtime reindexing and abstracting the underlying index name from applications.
Question 6: Which HTTP method is used to update an existing document using the Elasticsearch Update API?
- PUT
- PATCH
- POST (Correct answer)
- GET
Correct answer: POST
The Update API uses a POST request to `/<index>/_update/<id>` to perform partial document updates or script-based updates.
Question 7: What does the `doc_values` field mapping parameter control in Elasticsearch?
- Whether the field is searchable via full-text search
- On-disk data structures used for sorting and aggregations (Correct answer)
- The number of terms stored in the inverted index
- The maximum field value allowed during indexing
Correct answer: On-disk data structures used for sorting and aggregations
doc_values are on-disk data structures stored at index time that enable efficient sorting, aggregations, and access in scripts.
What is the default number of primary shards for an index created in Elasticsearch 7.x and later?