count.asciidoc 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. [[cat-count]]
  2. === cat count API
  3. ++++
  4. <titleabbrev>cat count</titleabbrev>
  5. ++++
  6. [IMPORTANT]
  7. ====
  8. cat APIs are only intended for human consumption using the command line or {kib}
  9. console. They are _not_ intended for use by applications. For application
  10. consumption, use the <<search-count,count API>>.
  11. ====
  12. Provides quick access to a document count for a data stream, an index, or an
  13. entire cluster.
  14. NOTE: The document count only includes live documents, not deleted documents
  15. which have not yet been removed by the merge process.
  16. [[cat-count-api-request]]
  17. ==== {api-request-title}
  18. `GET /_cat/count/<target>`
  19. `GET /_cat/count`
  20. [[cat-count-api-prereqs]]
  21. ==== {api-prereq-title}
  22. * If the {es} {security-features} are enabled, you must have the `read`
  23. <<privileges-list-indices,index privilege>> for any data stream, index, or alias
  24. you retrieve.
  25. [[cat-count-api-path-params]]
  26. ==== {api-path-parms-title}
  27. `<target>`::
  28. (Optional, string) Comma-separated list of data streams, indices, and aliases
  29. used to limit the request. Supports wildcards (`*`). To target all data streams
  30. and indices, omit this parameter or use `*` or `_all`.
  31. [[cat-count-api-query-params]]
  32. ==== {api-query-parms-title}
  33. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=http-format]
  34. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=cat-h]
  35. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=help]
  36. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=cat-s]
  37. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=cat-v]
  38. [[cat-count-api-example]]
  39. ==== {api-examples-title}
  40. [[cat-count-api-example-ind]]
  41. ===== Example with an individual data stream or index
  42. The following `count` API request retrieves the document count for the
  43. `my-index-000001` data stream or index.
  44. [source,console,id=cat-count-individual-example]
  45. --------------------------------------------------
  46. GET /_cat/count/my-index-000001?v=true
  47. --------------------------------------------------
  48. // TEST[setup:my_index_big]
  49. The API returns the following response:
  50. [source,txt]
  51. --------------------------------------------------
  52. epoch timestamp count
  53. 1475868259 15:24:20 120
  54. --------------------------------------------------
  55. // TESTRESPONSE[s/1475868259 15:24:20/\\d+ \\d+:\\d+:\\d+/ non_json]
  56. [[cat-count-api-example-all]]
  57. ===== Example with all data streams and indices in a cluster
  58. The following `count` API request retrieves the document count for all data
  59. streams and indices in the cluster.
  60. [source,console,id=cat-count-all-example]
  61. --------------------------------------------------
  62. GET /_cat/count?v=true
  63. --------------------------------------------------
  64. // TEST[setup:my_index_big]
  65. // TEST[s/^/POST test\/_doc\?refresh\n{"test": "test"}\n/]
  66. The API returns the following response:
  67. [source,txt]
  68. --------------------------------------------------
  69. epoch timestamp count
  70. 1475868259 15:24:20 121
  71. --------------------------------------------------
  72. // TESTRESPONSE[s/1475868259 15:24:20/\\d+ \\d+:\\d+:\\d+/ non_json]