List all indexes on ElasticSearch server?
For a concise list of all indices in your cluster, call
curl http://localhost:9200/_aliases
this will give you a list of indices and their aliases.
If you want it pretty-printed, add pretty=true
:
curl http://localhost:9200/_aliases?pretty=true
The result will look something like this, if your indices are called old_deuteronomy
and mungojerrie
:
{
"old_deuteronomy" : {
"aliases" : { }
},
"mungojerrie" : {
"aliases" : {
"rumpleteazer" : { },
"that_horrible_cat" : { }
}
}
}
You can query localhost:9200/_status
and that will give you a list of indices and information about each. The response will look something like this:
{
"ok" : true,
"_shards" : { ... },
"indices" : {
"my_index" : { ... },
"another_index" : { ... }
}
}
Try
curl 'localhost:9200/_cat/indices?v'
It will give you following self explanatory output in a tabular manner
health index pri rep docs.count docs.deleted store.size pri.store.size
yellow customer 5 1 0 0 495b 495b
The _stats command provides ways to customize the results by specifying the metrics wished. To get the indices the query is as follows:
GET /_stats/indices
The general format of the _stats
query is:
/_stats
/_stats/{metric}
/_stats/{metric}/{indexMetric}
/{index}/_stats
/{index}/_stats/{metric}
Where the metrics are:
indices, docs, store, indexing, search, get, merge,
refresh, flush, warmer, filter_cache, id_cache,
percolate, segments, fielddata, completion
As an exercice to myself, I've written a small elasticsearch plugin providing the functionality to list elasticsearch indices without any other information. You can find it at the following url:
http://blog.iterativ.ch/2014/04/11/listindices-writing-your-first-elasticsearch-java-plugin/
https://github.com/iterativ/elasticsearch-listindices