Elasticsearch Understanding Elasticsearch Cat Indices

By Opster Team

Updated: Jul 23, 2023

| 2 min read

Introduction 

Elasticsearch cat indices is a command-line tool that provides a concise and human-readable overview of your cluster indices. It is a part of the Elasticsearch cat APIs, which are designed to present data about your Elasticsearch cluster in a format that’s easy to read and understand. The cat indices API is particularly useful for getting a quick snapshot of the state of your indices in your cluster. If you want to learn about Elasticsearch field size – how to calculate the storage size of specific fields in an Index, check out this guide. 

How to Use Elasticsearch Cat Indices

To use the cat indices API, you need to send an HTTP request to your Elasticsearch cluster. The basic syntax of the request is as follows:

GET /_cat/indices?v

This command will return a list of all indices in your cluster, along with some basic information about each one, such as its health status, number of documents, and total size.

You can also add parameters to the request to customize the output. For example, you can add the `h` parameter to specify which columns to display:

GET /_cat/indices?v&h=index,health,status,docs.count,store.size

This command will only display the index name, health status, index status, document count, and store size.

Interpreting the Output

The output of the cat indices API is a table with one row for each index and columns for various properties of the index. Here’s a brief explanation of some of the most important columns:

  • `health`: The health status of the index. It can be “green”, “yellow”, or “red”. Green means that all primary and replica shards are active. Yellow means that all primary shards are active, but some replica shards are not. Red means that some primary shards are not active.
  • `status`: The status of the index. It can be “open” or “closed”.
  • `docs.count`: The number of documents in the index.
  • `store.size`: The total size of the index on disk.

Advanced Usage

The cat indices API also supports more advanced features. For example, you can use the `s` parameter to sort the output by any column:

GET /_cat/indices?v&s=store.size:desc

This command will sort the indices by size in descending order.

You can also use the `format` parameter to specify the output format. By default, the output is in plain text, but you can also get it in JSON, YAML, or CBOR:

GET /_cat/indices?v&format=json

This command will return the output in JSON format.

Conclusion 

In conclusion, the Elasticsearch cat indices API is a powerful tool for monitoring and managing your Elasticsearch cluster. It provides a quick and easy way to get a snapshot of the state of your indices, and it supports a wide range of customization options to fit your specific needs.