Reputation: 4886
I have elastic search rollover indexes like as shown below
/logs-dev-myapp-000001
/logs-dev-myapp-000002
/logs-dev-myapp-000003
/logs-dev-myapp-000004
/logs-dev-myapp-000005
:
:
/logs-dev-myapp-000030
Can anyone please tell me how to find all the rollover indexes from a ES GET query. Also is there any way in which we can find the oldest and newest index rollover indexes in Elastic Search
I am using ElasticSearch-6.4 Version
Upvotes: 1
Views: 811
Reputation: 8840
To know the list of indexes using its prefix, you can make use of below URL
http://<your_host_name>:<your_port_num>/_cat/indices/logs-dev-myapp-*?v&s=i
or use below GET query
GET /_cat/indices/logs-dev-myapp-*?v&s=i
Now for the highest and lowest, I suppose when you mean it you are asking with respect to documents count, you can make use of the below aggregation query.
Note that the below query would also display list of indexes.
POST logs-dev-myapp-*/_search
{
"size":0,
"aggs":{
"indices":{
"terms":{
"field":"_index",
"size":100
}
},
"max":{
"max_bucket":{
"buckets_path":"indices._count"
}
},
"min":{
"min_bucket":{
"buckets_path":"indices._count"
}
}
},
"sort":[
{
"_index":{
"order":"asc"
}
}
],
"script_fields":{
"index_name":{
"script":{
"lang":"painless",
"source":"doc['_index']"
}
}
}
}
Refer to this LINK for more info in the field _index
.
And I've made use of Max Bucket and Min Bucket pipeline aggregations with Terms Aggregation
Let me know if it helps!
Upvotes: 2