Complete the code to set the number of shards for an index.
PUT /my_index
{
"settings": {
"number_of_shards": [1]
}
}The default and minimum number of shards is 1, which allows the index to store data and scale properly.
Complete the code to update the refresh interval for better indexing performance.
PUT /my_index/_settings
{
"index": {
"refresh_interval": [1]
}
}Setting refresh_interval to "-1" disables automatic refresh, improving indexing speed during heavy writes.
Fix the error in the query to filter documents by a field value.
{
"query": {
"term": {
"status": [1]
}
}
}The term query requires the value to be a string in quotes, like "active".
Fill both blanks to create a range query filtering documents with age greater than 30.
{
"query": {
"range": {
"age": {
"[1]": [2]
}
}
}
}Using "gt" means greater than, and 30 is the value to compare.
Fill all three blanks to create an aggregation that counts documents per status where count is greater than 5.
{
"aggs": {
"status_count": {
"terms": {
"field": "[1]"
},
"aggs": {
"filtered_count": {
"bucket_selector": {
"buckets_path": {
"count": "_count"
},
"script": "params.count [2] [3]"
}
}
}
}
}
}The aggregation groups by the "status" field, then filters buckets where count > 5.