count.asciidoc 3.1 KB

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