How to list all the indexes in Elasticsearch

Elasticsearch, a powerful distributed search engine, plays a crucial role in modern applications for its ability to efficiently store and retrieve vast amounts of data. When working with Elasticsearch, administrators often need to monitor and manage the cluster, including obtaining essential information about its indices.

List all indexes in Elasticsearch

To list all the indexes in Elasticsearch, we can use the _cat API provided by Elasticsearch. The _cat API provides a simple and human-readable way to get information about the cluster, nodes, and indices.

Using cURL

To list all the indexes, we can make a simple HTTP GET request to the _cat/indices endpoint. This can be done using tools like cURL or directly from programming languages that support making HTTP requests, such as Python, JavaScript, or Java.

Run the following command in the terminal below:

curl -X GET "http://your_elasticsearch_host:9200/_cat/indices?v"

Replace the your_elasticsearch_host with the hostname or IP address of your Elasticsearch server.

Terminal 1
Terminal
Loading...

Using Python and the requests library:

We can also use Python and the requests library to make the HTTP request.

import requests
url = 'http://your_elasticsearch_host:9200/_cat/indices?v'
response = requests.get(url)
if response.status_code == 200:
print(response.text)
else:
print("Failed to retrieve indices. Status code: {response.status_code}")

Replace the your_elasticsearch_host with the hostname or IP address of your Elasticsearch server.

Output

Regardless of the method we choose, the response will include information about all the indexes in our Elasticsearch cluster, such as their names, document counts, storage sizes, and more. The v parameter in the URL enables a verbose output that includes column headers for better readability.

The output of the code to list all the indexes in Elasticsearch will be a tabular representation of the indices, including their names and various metadata. The output will look similar to the following:

health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
yellow open index1 t-1d8Q6XRsWWSXVtOQx3U 1 1 100 10 50kb 25kb
yellow open index2 g-5F5GzQqgx9Z0MKJI55g 1 1 500 50 250kb 125kb
green open index3 q-Hs5LE3TdeFVzMoP9Q0g 1 1 1000 0 500kb 250kb
yellow open index4 w-Wl8a5QrzWDFRcJoK4v 1 1 750 100 375kb 187kb
Sample output

Each row represents an index, and the columns provide different information about the indexes, including:

  • health: The health status of the index (green, yellow, or red).

  • status: The status of the index (open or closed).

  • index: The name of the index.

  • uuid: The unique identifier of the index.

  • pri: The number of primary shards for the index.

  • rep: The number of replica shards for the index.

  • docs.count: The number of documents in the index.

  • docs.deleted: The number of deleted documents in the index.

  • store.size: The total size of the primary and replica shards.

  • pri.store.size: The size of the primary shards.

Indices are collections of similar documents in Elasticsearch, while shards are smaller units that divide an index, allowing for distributed storage and scalability.

Note: The actual output may vary depending on the indices present in your Elasticsearch cluster and their respective metadata. The data shown above is just a sample representation, and your output will include the actual information for your indexes.

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved