Core
API v1.x
1

You are currently looking at the documentation of a previous version of Kuzzle. We strongly recommend that you use the latest version. You can also use the version selector in the top menu.

count #

Counts documents in a collection.

A query can be provided to alter the count result, otherwise returns the total number of documents in the collection.


Query Syntax #

HTTP #

Copied to clipboard!
URL: http://kuzzle:7512/<index>/<collection>/_count[?includeTrash=<boolean>]
Method: POST
Body:
Copied to clipboard!
{
  "query": {
        "match_all": {}
    }
}

Other protocols #

Copied to clipboard!
{
  "index": "<index>",
  "collection": "<collection>",
  "controller": "document",
  "action": "count",
  "body": {
    "query": {
        "match_all": {}
    }
  },
  "includeTrash": false
}

Arguments #

  • collection: collection name
  • index: index name

Optional: #

  • includeTrash: include documents from the trashcan

Body properties #

Optional: #


Response #

Returns an object with the count property, an integer showing the number of documents matching the provided search query:

Copied to clipboard!
{
  "status": 200,
  "error": null,
  "index": "<index>",
  "collection": "<collection>",
  "controller": "document",
  "action": "count",
  "requestId": "<unique request identifier>",
  "result": {
    "count": 42
  }
}