Get a document count

  • POST also GET /_cat/count/{index}
  • POST also GET /_cat/count
Auth

Get 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.

Important

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.

Note

Starting in Elasticsearch 9.3.0, this endpoint also supports the POST method. This is primarily intended for project routing in serverless environments.

Required authorization

Index privileges read

Path parameters

index union string | string[] optional

A comma-separated list of data streams, indices, and aliases used to limit the request. It supports wildcards (*). To target all data streams and indices, omit this parameter or use * or _all.

Leave it out to use /_cat/count.

Query parameters

h union oneOf

A comma-separated list of columns names to display. It supports simple wildcards.

Supported values include:

  • epoch (or t, time): The Unix epoch time in seconds since 1970-01-01 00:00:00.
  • timestamp (or ts, hms, hhmmss): The current time in HH:MM:SS format.
  • count (or dc, docs.count, docsCount): The document count in the cluster or index.
Values: epoch t time timestamp ts hms hhmmss count dc docs.count docsCount
s union string | string[]

List of columns that determine how the table should be sorted. Sorting defaults to ascending and can be changed by setting :asc or :desc as a suffix to the column name.

format string · default: text

Specifies the format to return the columnar data in, can be set to text, json, cbor, yaml, or smile.

help boolean · default: false

When set to true will output available columns. This option can't be combined with any other query string option.

v boolean · default: false

When set to true will enable verbose output.

bytes enum

Sets the units for columns that contain a byte-size value. Note that byte-size value units work in terms of powers of 1024. For instance 1kb means 1024 bytes, not 1000 bytes. If omitted, byte-size values are rendered with a suffix such as kb, mb, or gb, chosen such that the numeric value of the column is as small as possible whilst still being at least 1.0. If given, byte-size values are rendered as an integer with no suffix, representing the value of the column in the chosen unit. Values that are not an exact multiple of the chosen unit are rounded down.

Values: b kb mb gb tb pb
time enum

Sets the units for columns that contain a time duration. If omitted, time duration values are rendered with a suffix such as ms, s, m or h, chosen such that the numeric value of the column is as small as possible whilst still being at least 1.0. If given, time duration values are rendered as an integer with no suffix. Values that are not an exact multiple of the chosen unit are rounded down.

Values: nanos micros ms s m h d

Request body

Type: object

Response

application/json
<array> object[]
epoch union oneOf

seconds since 1970-01-01 00:00:00

One of: number or string
timestamp string

time in HH:MM:SS

count string

the document count