count.asciidoc 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 index
  18. alias you retrieve.
  19. [[cat-count-api-path-params]]
  20. ==== {api-path-parms-title}
  21. `<target>`::
  22. (Optional, string)
  23. Comma-separated list of data streams, indices, and index aliases used to limit
  24. the request. Wildcard expressions (`*`) are supported.
  25. +
  26. To target all data streams and indices in a cluster, omit this parameter or use
  27. `_all` or `*`.
  28. [[cat-count-api-query-params]]
  29. ==== {api-query-parms-title}
  30. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=http-format]
  31. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=cat-h]
  32. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=help]
  33. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=cat-s]
  34. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=cat-v]
  35. [[cat-count-api-example]]
  36. ==== {api-examples-title}
  37. [[cat-count-api-example-ind]]
  38. ===== Example with an individual data stream or index
  39. The following `count` API request retrieves the document count for the
  40. `my-index-000001` data stream or index.
  41. [source,console,id=cat-count-individual-example]
  42. --------------------------------------------------
  43. GET /_cat/count/my-index-000001?v=true
  44. --------------------------------------------------
  45. // TEST[setup:my_index_big]
  46. The API returns the following response:
  47. [source,txt]
  48. --------------------------------------------------
  49. epoch timestamp count
  50. 1475868259 15:24:20 120
  51. --------------------------------------------------
  52. // TESTRESPONSE[s/1475868259 15:24:20/\\d+ \\d+:\\d+:\\d+/ non_json]
  53. [[cat-count-api-example-all]]
  54. ===== Example with all data streams and indices in a cluster
  55. The following `count` API request retrieves the document count for all data
  56. streams and indices in the cluster.
  57. [source,console,id=cat-count-all-example]
  58. --------------------------------------------------
  59. GET /_cat/count?v=true
  60. --------------------------------------------------
  61. // TEST[setup:my_index_big]
  62. // TEST[s/^/POST test\/_doc\?refresh\n{"test": "test"}\n/]
  63. The API returns the following response:
  64. [source,txt]
  65. --------------------------------------------------
  66. epoch timestamp count
  67. 1475868259 15:24:20 121
  68. --------------------------------------------------
  69. // TESTRESPONSE[s/1475868259 15:24:20/\\d+ \\d+:\\d+:\\d+/ non_json]