ElasticSearch ElasticSearch MCQ 2 — Questions and Answers
Question 1: Which Elasticsearch data type should you use to store a field that will be used for both full-text search and exact keyword matching?
- text
- keyword
- multi-field with text and keyword sub-fields (Correct answer)
- binary
Correct answer: multi-field with text and keyword sub-fields
A multi-field mapping allows the same field to be indexed as both 'text' for full-text search and 'keyword' for exact matching and aggregations.
Question 2: What happens when Elasticsearch receives a document with a field not defined in the current mapping and dynamic mapping is enabled?
- The document is rejected with a mapping exception
- The field is ignored silently
- Elasticsearch automatically adds the new field to the mapping (Correct answer)
- The document is stored but the field is not indexed
Correct answer: Elasticsearch automatically adds the new field to the mapping
With dynamic mapping enabled (the default), Elasticsearch detects and maps new fields automatically when a document containing them is first indexed.
Question 3: In an Elasticsearch cluster, what is the role of a 'coordinating-only' node?
- It stores no data and only routes requests and aggregates results (Correct answer)
- It manages cluster state and master election
- It handles only ingest pipelines
- It performs only machine learning tasks
Correct answer: It stores no data and only routes requests and aggregates results
A coordinating-only node acts as a smart load balancer, routing requests to appropriate shards and merging results without holding data or cluster state.
Question 4: Which query clause in Elasticsearch does NOT affect the relevance score of matching documents?
- match
- multi_match
- filter (Correct answer)
- function_score
Correct answer: filter
Filter clauses operate in filter context, meaning they only determine if a document matches (yes/no) without calculating or contributing to a relevance score.
Question 5: What is the purpose of the 'refresh_interval' setting in Elasticsearch?
- Controls how often snapshots are taken
- Controls how often a new segment is written making recent changes searchable (Correct answer)
- Controls how often the cluster state is updated
- Controls how often shards are rebalanced
Correct answer: Controls how often a new segment is written making recent changes searchable
The refresh_interval (default 1s) determines how frequently Elasticsearch writes a new Lucene segment, making recently indexed documents available for search.
Question 6: Which Elasticsearch aggregation type would you use to compute the median value of a numeric field?
- avg
- percentiles (Correct answer)
- stats
- extended_stats
Correct answer: percentiles
The percentiles aggregation computes approximate percentile values; specifying the 50th percentile gives the median.
Question 7: What does the 'doc_values' field option do in Elasticsearch?
- Stores field values in the inverted index for fast full-text search
- Stores field values in a column-oriented on-disk structure optimized for sorting and aggregations (Correct answer)
- Enables highlighting for the field
- Controls whether the field is stored in the _source
Correct answer: Stores field values in a column-oriented on-disk structure optimized for sorting and aggregations
Doc values are an on-disk column-oriented data structure that enables efficient sorting, aggregations, and scripting on field values.
Which Elasticsearch data type should you use to store a field that will be used for both full-text search and exact keyword matching?