count.asciidoc 2.5 KB

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