ElasticSearch ElasticSearch 4 — Questions and Answers
Question 1: What is the purpose of the `index.number_of_replicas` setting in Elasticsearch?
- Controls how many nodes the index is distributed across
- Sets the number of replica shards per primary shard for redundancy (Correct answer)
- Defines how many times a document is replicated before acknowledgment
- Limits the number of concurrent write operations
Correct answer: Sets the number of replica shards per primary shard for redundancy
The `index.number_of_replicas` setting defines how many replica copies exist for each primary shard, providing high availability and read scalability.
Question 2: Which Elasticsearch query would you use to search across multiple fields simultaneously?
- term query
- multi_match query (Correct answer)
- nested query
- percolate query
Correct answer: multi_match query
The multi_match query extends the match query to run across multiple fields, with options for best_fields, most_fields, and cross_fields types.
Question 3: What does the `_score` field represent in an Elasticsearch search response?
- The number of matching terms found in the document
- A relevance score indicating how well the document matches the query (Correct answer)
- The timestamp of when the document was last updated
- The percentage of query clauses that matched
Correct answer: A relevance score indicating how well the document matches the query
The `_score` field is a floating-point relevance score computed by Elasticsearch (using BM25 by default) indicating how well the document matches the query.
Question 4: What is the Elasticsearch Reindex API used for?
- Rebuilding the inverted index for a single field
- Copying documents from one index to another (Correct answer)
- Resetting shard allocation settings
- Refreshing segment files on disk
Correct answer: Copying documents from one index to another
The Reindex API copies documents from a source index to a destination index, allowing schema changes, data migration, or index consolidation.
Question 5: Which Elasticsearch feature allows you to define rules that automatically apply to new indices based on name patterns?
- Index lifecycle policies
- Index templates (Correct answer)
- Dynamic field mappings
- Index aliases
Correct answer: Index templates
Index templates allow you to define settings, mappings, and aliases that are automatically applied when a new index is created matching a specified pattern.
Question 6: What is a 'bucket' aggregation in Elasticsearch?
- An aggregation that computes a single numeric value like sum or average
- An aggregation that groups documents into logical groups called buckets (Correct answer)
- An aggregation that transforms stored field values
- An aggregation that scores documents against a threshold
Correct answer: An aggregation that groups documents into logical groups called buckets
Bucket aggregations group documents into buckets based on field values, ranges, or other criteria, and can contain sub-aggregations.
Question 7: In Elasticsearch, what is the `filter` context in a bool query?
- Queries that must match and contribute to relevance scoring
- Queries that are cached and do not affect relevance scores (Correct answer)
- Queries that boost document scores if they match
- Queries that are applied only after the initial query phase
Correct answer: Queries that are cached and do not affect relevance scores
The filter context executes queries purely for yes/no matching without computing relevance scores, and results are automatically cached for performance.
What is the purpose of the `index.number_of_replicas` setting in Elasticsearch?