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
URL: http://kuzzle:7512/<index>/<collection>/_count
Method: POST
Body:
{
"query": {
"match_all": {}
}
}
Other protocols
{
"index": "<index>",
"collection": "<collection>",
"controller": "document",
"action": "count",
"body": {
"query": {
"match_all": {}
}
}
}
Arguments
collection
: collection nameindex
: index name
Body properties
Optional:
query
: if provided, will count only documents matching this search query. Uses the ElasticSearch Query DSL syntax.
Response
Returns an object with the count
property, an integer showing the number of documents matching the provided search query:
{
"status": 200,
"error": null,
"index": "<index>",
"collection": "<collection>",
"controller": "document",
"action": "count",
"requestId": "<unique request identifier>",
"result": {
"count": 42
}
}