2013-11-15 09:14:39 +08:00
|
|
|
[[cat-count]]
|
2019-08-13 20:35:08 +08:00
|
|
|
=== cat count API
|
|
|
|
++++
|
|
|
|
<titleabbrev>cat count</titleabbrev>
|
|
|
|
++++
|
2013-11-15 09:14:39 +08:00
|
|
|
|
2022-02-04 15:55:19 +08:00
|
|
|
[IMPORTANT]
|
|
|
|
====
|
|
|
|
cat APIs are only intended for human consumption using the command line or {kib}
|
|
|
|
console. They are _not_ intended for use by applications. For application
|
|
|
|
consumption, use the <<search-count,count API>>.
|
|
|
|
====
|
|
|
|
|
2020-07-01 03:06:51 +08:00
|
|
|
Provides quick access to a document count for a data stream, an index, or an
|
|
|
|
entire cluster.
|
2019-08-06 20:36:22 +08:00
|
|
|
|
|
|
|
NOTE: The document count only includes live documents, not deleted documents
|
|
|
|
which have not yet been removed by the merge process.
|
|
|
|
|
|
|
|
|
|
|
|
[[cat-count-api-request]]
|
|
|
|
==== {api-request-title}
|
|
|
|
|
2020-07-01 03:06:51 +08:00
|
|
|
`GET /_cat/count/<target>`
|
2019-08-06 20:36:22 +08:00
|
|
|
|
2019-10-10 20:29:27 +08:00
|
|
|
`GET /_cat/count`
|
|
|
|
|
2021-01-20 23:19:20 +08:00
|
|
|
[[cat-count-api-prereqs]]
|
|
|
|
==== {api-prereq-title}
|
|
|
|
|
|
|
|
* If the {es} {security-features} are enabled, you must have the `read`
|
2021-05-28 04:00:57 +08:00
|
|
|
<<privileges-list-indices,index privilege>> for any data stream, index, or alias
|
|
|
|
you retrieve.
|
2019-08-06 20:36:22 +08:00
|
|
|
|
|
|
|
[[cat-count-api-path-params]]
|
|
|
|
==== {api-path-parms-title}
|
|
|
|
|
2020-07-01 03:06:51 +08:00
|
|
|
`<target>`::
|
2021-05-28 04:00:57 +08:00
|
|
|
(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`.
|
2019-08-06 20:36:22 +08:00
|
|
|
|
|
|
|
[[cat-count-api-query-params]]
|
|
|
|
==== {api-query-parms-title}
|
|
|
|
|
2020-06-02 06:55:05 +08:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=http-format]
|
2019-08-06 20:36:22 +08:00
|
|
|
|
2020-06-02 06:55:05 +08:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=cat-h]
|
2019-08-06 20:36:22 +08:00
|
|
|
|
2020-06-02 06:55:05 +08:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=help]
|
2019-08-06 20:36:22 +08:00
|
|
|
|
2020-06-02 06:55:05 +08:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=cat-s]
|
2019-08-06 20:36:22 +08:00
|
|
|
|
2020-06-02 06:55:05 +08:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=cat-v]
|
2019-08-06 20:36:22 +08:00
|
|
|
|
|
|
|
|
|
|
|
[[cat-count-api-example]]
|
|
|
|
==== {api-examples-title}
|
|
|
|
|
|
|
|
[[cat-count-api-example-ind]]
|
2020-07-01 03:06:51 +08:00
|
|
|
===== Example with an individual data stream or index
|
2019-08-06 20:36:22 +08:00
|
|
|
|
2020-07-01 03:06:51 +08:00
|
|
|
The following `count` API request retrieves the document count for the
|
2020-08-03 21:26:17 +08:00
|
|
|
`my-index-000001` data stream or index.
|
2013-11-15 09:14:39 +08:00
|
|
|
|
2019-10-08 05:06:49 +08:00
|
|
|
[source,console,id=cat-count-individual-example]
|
2013-11-15 09:14:39 +08:00
|
|
|
--------------------------------------------------
|
2021-01-12 06:19:23 +08:00
|
|
|
GET /_cat/count/my-index-000001?v=true
|
2016-10-08 04:28:49 +08:00
|
|
|
--------------------------------------------------
|
2020-08-03 21:26:17 +08:00
|
|
|
// TEST[setup:my_index_big]
|
2016-10-08 04:28:49 +08:00
|
|
|
|
2019-08-06 20:36:22 +08:00
|
|
|
|
|
|
|
The API returns the following response:
|
2016-10-08 04:28:49 +08:00
|
|
|
|
2016-10-25 22:56:30 +08:00
|
|
|
[source,txt]
|
2016-10-08 04:28:49 +08:00
|
|
|
--------------------------------------------------
|
|
|
|
epoch timestamp count
|
2019-08-06 20:36:22 +08:00
|
|
|
1475868259 15:24:20 120
|
2016-10-08 04:28:49 +08:00
|
|
|
--------------------------------------------------
|
2019-08-06 20:36:22 +08:00
|
|
|
// TESTRESPONSE[s/1475868259 15:24:20/\\d+ \\d+:\\d+:\\d+/ non_json]
|
|
|
|
|
|
|
|
[[cat-count-api-example-all]]
|
2020-07-01 03:06:51 +08:00
|
|
|
===== Example with all data streams and indices in a cluster
|
2016-03-01 20:39:54 +08:00
|
|
|
|
2020-07-01 03:06:51 +08:00
|
|
|
The following `count` API request retrieves the document count for all data
|
|
|
|
streams and indices in the cluster.
|
2016-03-01 20:39:54 +08:00
|
|
|
|
2019-10-08 05:06:49 +08:00
|
|
|
[source,console,id=cat-count-all-example]
|
2013-11-15 09:14:39 +08:00
|
|
|
--------------------------------------------------
|
2021-01-12 06:19:23 +08:00
|
|
|
GET /_cat/count?v=true
|
2016-10-08 04:28:49 +08:00
|
|
|
--------------------------------------------------
|
2020-08-03 21:26:17 +08:00
|
|
|
// TEST[setup:my_index_big]
|
2019-10-11 17:23:55 +08:00
|
|
|
// TEST[s/^/POST test\/_doc\?refresh\n{"test": "test"}\n/]
|
2019-08-06 20:36:22 +08:00
|
|
|
|
|
|
|
The API returns the following response:
|
2016-10-08 04:28:49 +08:00
|
|
|
|
2016-10-25 22:56:30 +08:00
|
|
|
[source,txt]
|
2016-10-08 04:28:49 +08:00
|
|
|
--------------------------------------------------
|
|
|
|
epoch timestamp count
|
2019-08-06 20:36:22 +08:00
|
|
|
1475868259 15:24:20 121
|
2016-10-08 04:28:49 +08:00
|
|
|
--------------------------------------------------
|
2019-06-10 21:33:32 +08:00
|
|
|
// TESTRESPONSE[s/1475868259 15:24:20/\\d+ \\d+:\\d+:\\d+/ non_json]
|