count.asciidoc 2.7 KB

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