Listing All Indexes in Elasticsearch Cluster

Published on December 10, 2015 by

If you want to list all of the indexes within an Elasticsearch cluster, then there are a few ways to do just that. The following examples are going to assume the usage of cURL to issue HTTP requests, but any similar tool will do as well. It is also possible to use the Kibana plugin Sense, which provides you with a convenient user interface that is easier to use than the command line terminal.

The first way to do it uses the _cat API like below.

curl http://localhost:9200/_cat/indices?v

The v query parameter adds a header row to the output. Here is some sample output from the above command:

health status index     pri rep docs.count docs.deleted store.size pri.store.size 
yellow open   .kibana     1   1          1            0      3.1kb        3.1kb 
yellow open   myindex     5   1          0            0       650b         650b 

As you can see in the above example, this command also shows some useful information about the indexes, such as their health, number of shards, documents and more.

In contrast to the _cat API, the following commands return JSON instead of a “human friendly” output. Also, they do not provide any of the above information, so which command you should use depends on your use case, i.e. whether or not you need a JSON response (e.g. for rendering the output in your application) and if you need any of the information that the above command provides.

You can also use the _aliases API, which will also return any aliases that each index may have.

curl http://localhost:9200/_aliases

Below is some sample output for the above command.

{".kibana":{"aliases":{}},"myindex":{"aliases":{}}}

Note that if you want pretty JSON to be returned so that it is easier to read, simply append ?pretty=1 to the command, like this: curl http://localhost:9200/_aliases?pretty=1. This will give the following result.

{
  ".kibana" : {
    "aliases" : { }
  },
  "myindex" : {
    "aliases" : { }
  }
}

That’s all it takes to list all indexes on an Elasticsearch server or cluster.

Featured

Learn Elasticsearch today!

Take an online course and become an Elasticsearch champion!

Here is what you will learn:

  • The architecture of Elasticsearch
  • Mappings and analyzers
  • Many kinds of search queries (simple and advanced alike)
  • Aggregations, stemming, auto-completion, pagination, filters, fuzzy searches, etc.
  • ... and much more!
Elasticsearch logo
Author avatar
Bo Andersen

About the Author

I am a back-end web developer with a passion for open source technologies. I have been a PHP developer for many years, and also have experience with Java and Spring Framework. I currently work full time as a lead developer. Apart from that, I also spend time on making online courses, so be sure to check those out!

3 comments on »Listing All Indexes in Elasticsearch Cluster«

  1. Mohammed Meziani

    Hi Anderson,
    thanks a lot for input regarding the installation of ES on Mac . It was really helpfull and very clear.

    I have a question: today is my first day to start learning ES. Could you recommand to me some books or how i can learn ES efficiently and quickly.

    Thanks again and best regards

    Mohammed

    • Hello, Mohammed,

      Thank you for your feedback – I am happy that it helped!

      Well, it just so happens that I made an online course on Elasticsearch, which you can find here. You are welcome to send me a message on this site, and I will provide you with a 50% off coupon code. :-)

  2. abc g

    why dont i get any output when i try to view data in elasticsearch using curl request

Leave a Reply

Your e-mail address will not be published.