cat count API

cat count API

New API reference

For the most up-to-date API details, refer to Compact and aligned text (CAT) APIs..

cat APIs are only intended for human consumption using the command line or Kibana console. They are not intended for use by applications. For application consumption, use the count API.

Provides quick access to a document count for a data stream, an index, or an entire cluster.

The document count only includes live documents, not deleted documents which have not yet been removed by the merge process.

Request

GET /_cat/count/<target>

GET /_cat/count

Prerequisites

  • If the Elasticsearch security features are enabled, you must have the read index privilege for any data stream, index, or alias you retrieve.

Path parameters

<target>

(Optional, string) Comma-separated list of data streams, indices, and aliases used to limit the request. Supports wildcards (*). To target all data streams and indices, omit this parameter or use * or _all.

Query parameters

format

(Optional, string) Short version of the HTTP accept header. Valid values include JSON, YAML, etc.

h

(Optional, string) Comma-separated list of column names to display.

help

(Optional, Boolean) If true, the response includes help information. Defaults to false.

s

(Optional, string) Comma-separated list of column names or column aliases used to sort the response.

v

(Optional, Boolean) If true, the response includes column headings. Defaults to false.

Examples

Example with an individual data stream or index

The following count API request retrieves the document count for the my-index-000001 data stream or index.

  1. resp = client.cat.count(
  2. index="my-index-000001",
  3. v=True,
  4. )
  5. print(resp)
  1. response = client.cat.count(
  2. index: 'my-index-000001',
  3. v: true
  4. )
  5. puts response
  1. const response = await client.cat.count({
  2. index: "my-index-000001",
  3. v: "true",
  4. });
  5. console.log(response);
  1. GET /_cat/count/my-index-000001?v=true

The API returns the following response:

  1. epoch timestamp count
  2. 1475868259 15:24:20 120

Example with all data streams and indices in a cluster

The following count API request retrieves the document count for all data streams and indices in the cluster.

  1. resp = client.cat.count(
  2. v=True,
  3. )
  4. print(resp)
  1. response = client.cat.count(
  2. v: true
  3. )
  4. puts response
  1. const response = await client.cat.count({
  2. v: "true",
  3. });
  4. console.log(response);
  1. GET /_cat/count?v=true

The API returns the following response:

  1. epoch timestamp count
  2. 1475868259 15:24:20 121