A shard is a basic unit of storage in Elasticsearch. It holds a subset of the data in an index, allowing the data to be split across multiple nodes for better performance and scalability.
Click to reveal answer
beginner
What does the number_of_shards setting control?
It controls how many primary shards an index is divided into. This number cannot be changed after the index is created.
Click to reveal answer
beginner
What is a replica in Elasticsearch?
A replica is a copy of a primary shard. It provides fault tolerance and increases search capacity by allowing queries to run on multiple copies.
Click to reveal answer
intermediate
How does the number_of_replicas setting affect an index?
It sets how many copies of each primary shard are created. More replicas mean better fault tolerance and faster searches but use more storage.
Click to reveal answer
intermediate
Can you change the number_of_replicas after creating an index?
Yes, you can change the number_of_replicas at any time to add or remove replica shards without downtime.
Click to reveal answer
What happens if you increase the number_of_replicas for an index?
AMore copies of shards are created, improving fault tolerance and search speed.
BThe index data is deleted and recreated.
CThe number of primary shards increases.
DThe index becomes read-only.
✗ Incorrect
Increasing number_of_replicas creates more copies of primary shards, which helps with fault tolerance and allows more nodes to serve search requests.
Which setting cannot be changed after index creation?
Arefresh_interval
Bnumber_of_shards
Cnumber_of_replicas
Dindex.mapping.total_fields.limit
✗ Incorrect
The number_of_shards is fixed when the index is created and cannot be changed later.
Why do we use shards in Elasticsearch?
ATo encrypt data.
BTo compress data.
CTo backup data to external storage.
DTo split data across nodes for scalability and performance.
✗ Incorrect
Shards split the index data so Elasticsearch can store and search data efficiently across multiple nodes.
What is the default number_of_replicas in Elasticsearch?
A1
B2
C0
D3
✗ Incorrect
By default, Elasticsearch creates 1 replica for each primary shard.
If an Elasticsearch node fails, what helps keep the data available?
AIndex templates
BPrimary shards only
CReplica shards
DCluster settings
✗ Incorrect
Replica shards provide copies of data so if a node with primary shards fails, replicas can serve the data.
Explain the roles of shards and replicas in Elasticsearch index settings.
Think about how data is stored and protected in Elasticsearch.
You got /4 concepts.
Describe how changing the number_of_replicas affects an Elasticsearch cluster.
Consider the benefits and costs of having more copies of data.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of setting number_of_shards in an Elasticsearch index?
easy
A. To define the size of the index
B. To create backup copies of data
C. To split data into parts for faster searching
D. To set the maximum number of documents
Solution
Step 1: Understand shards role
Shards divide the index data into smaller parts to allow parallel searching.
Step 2: Differentiate shards from replicas
Replicas are copies for safety, not for splitting data.
Final Answer:
To split data into parts for faster searching -> Option C
Quick Check:
Shards = split data for speed [OK]
Hint: Shards split data, replicas copy data [OK]
Common Mistakes:
Confusing shards with replicas
Thinking shards create backups
Assuming shards set index size
2. Which of the following is the correct way to set 3 shards and 2 replicas in an Elasticsearch index creation JSON?
easy
A. { "settings": { "number_of_shards": 3, "number_of_replicas": 2 } }
B. { "settings": { "shards": 3, "replicas": 2 } }
C. { "settings": { "shard_count": 3, "replica_count": 2 } }
D. { "settings": { "num_shards": 3, "num_replicas": 2 } }
Solution
Step 1: Recall correct setting keys
The official keys are number_of_shards and number_of_replicas.
Step 2: Match keys with options
Only { "settings": { "number_of_shards": 3, "number_of_replicas": 2 } } uses the exact correct keys and valid JSON format.