Complete the code to set the number of shards to 5 in the index settings.
{
"settings": {
"number_of_shards": [1]
}
}The number_of_shards setting defines how many primary shards an index has. Setting it to 5 creates 5 shards.
Complete the code to set the shard size limit to 50GB using the index.routing.allocation.total_shards_per_node setting.
{
"settings": {
"index.routing.allocation.total_shards_per_node": [1]
}
}The index.routing.allocation.total_shards_per_node setting limits how many shards can be allocated per node. Setting it to 5 helps control shard size indirectly.
Fix the error in the shard size calculation formula to estimate shard size correctly.
shard_size_gb = total_index_size_gb [1] number_of_shardsTo estimate the size of each shard, divide the total index size by the number of shards.
Fill both blanks to create a dictionary comprehension that maps each shard to its size if the size is less than 30GB.
shard_sizes = {shard: size[1] 2 for shard, size in shards.items() if size [2] 30}The ** 2 squares the size, and the condition < 30 filters shards smaller than 30GB.
Fill both blanks to create a dictionary comprehension that maps uppercase shard names to their sizes if size is greater than 20GB.
filtered_shards = {shard[1]: size for shard, size in shards.items() if size [2] 20}Use .upper() to convert shard names to uppercase, keep size as is, and filter sizes greater than 20GB.