Complete the code to set the number of replicas to 2 for an index.
{
"settings": {
"number_of_replicas": [1]
}
}The number_of_replicas setting controls how many replica shards each primary shard has. Setting it to 2 means two copies of each shard will be created.
Complete the code to update the number of replicas to 1 for an existing index named 'products'.
PUT /products/_settings
{
"index": {
"number_of_replicas": [1]
}
}POST request.To update replicas for an existing index, you send a PUT request to /_settings with the new number_of_replicas. Here, setting it to 1 means one replica shard.
Fix the error in the code to correctly set replicas to 0 for the index 'logs'.
PUT /logs/_settings
{
"index": {
"number_of_replicas": [1]
}
}The number_of_replicas setting expects a number, not a string or boolean. So use 0 without quotes to disable replicas.
Fill both blanks to create a settings update that sets replicas to 3 and refresh interval to 30s.
PUT /archive/_settings
{
"number_of_replicas": [1],
"refresh_interval": [2]
}The number_of_replicas is a number, so use 3. The refresh_interval expects a string with time units, so use "30s" for 30 seconds.
Fill all three blanks to create a dictionary comprehension that maps index names to their replica count if replicas are greater than 1.
replica_counts = {index[1]: settings[2] for index, settings in indices.items() if settings.get('number_of_replicas', 0) [3] 1}This comprehension creates a new dictionary where keys are uppercase index names (index.upper()), values are the replica count from settings (settings['number_of_replicas']), and only includes those with replicas greater than 1.