SDK
SDK Javascript v5.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 #

Returns the number of documents matching the provided set of filters.

There is a small delay between the time a document is created and its availability in our search layer (usually a couple of seconds). That means that a document that was just created might not be returned by this function at first.

count(filters, [options], callback) #

ArgumentsTypeDescription
filtersJSON ObjectFilters in ElasticSearch Query DSL format
optionsJSON ObjectOptional parameters
callbackfunctionCallback handling the response

Options #

OptionTypeDescriptionDefault
queuablebooleanMake this request queuable or nottrue

Callback Response #

Returns a count for the number of document matches as an integer.

Usage #

// Using callbacks (NodeJS or Web Browser)
kuzzle
  .collection('collection', 'index')
  .count({}, function (err, res) {
    // ...
  });
// Using promises (NodeJS only)
kuzzle
  .collection('collection', 'index')
  .countPromise({})
  .then(res => {
    // ...
  });

Callback response:

12