How to get all indices in ElasticSearch with curl command?
To get all indices in ElasticSearch with curl, you can use the following command:
$ curl localhost:9200/_cat/indices
which outputs
$ curl localhost:9200/_cat/indices
yellow open test-index-yoan 5ChC9F9ZSGSRmooDAIrd9A 1 1 0 0 208b 208b
yellow open my-index-000001 Be3surqXQzy8_EVW9k1VZA 1 1 0 0 208b 208b
This example uses ES cat indices API.
All examples assume that ElasticSearch is running on localhost port 9200. If you are running these commands from your local machine to remote, you should replace localhost with your cluster/server IP and port.
Tip: You can also use your browser to access ES API. Since ElasticSearch is running on HTTP, you can just open http://localhost:9200/_cat/indices?h=index in your browser.
Let's look at some more ways to fetch index data in ElasticSearch.
Get indices with document count and column description
You can use ?v
flag to show additional information like document count and size.
$ curl 'localhost:9200/_cat/indices?v'
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
yellow open test-index-yoan 5ChC9F9ZSGSRmooDAIrd9A 1 1 0 0 208b 208b
yellow open my-index-000001 Be3surqXQzy8_EVW9k1VZA 1 1 0 0 208b 208b
Filter by index name
This command can be used with an index filter by name with * wildcard query.
$ curl "localhost:9200/_cat/indices/*yoan?v=true&s=index"
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
yellow open test-index-yoan 5ChC9F9ZSGSRmooDAIrd9A 1 1 0 0 208b 208b
Get only indices name
To list only indices names you can use the ?h=index
query parameter like so:
$ curl 'localhost:9200/_cat/indices?h=index'
test-index-yoan
my-index-000001