SDK
SDK C++ 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.

This SDK has been deprecated because of stability issues. It is not advised to use it in a production environment.

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.

Kuzzle uses the ElasticSearch Query DSL syntax.

Signature #

int count(const std::string& index, const std::string& collection);

int count(
    const std::string& index,
    const std::string& collection,
    const kuzzleio::query_options& options);

int count(
    const std::string& index,
    const std::string& collection,
    const std::string& query);

int count(
    const std::string& index,
    const std::string& collection,
    const std::string& query,
    const kuzzleio::query_options& options);

Arguments #

ArgumentTypeDescription
index
const std::string&
Index name
collection
const std::string&
Collection name
query
const std::string&
JSON string representing the query to match
options
kuzzleio::query_options*
Query options

options #

Additional query options

OptionType
(default)
Description
queuable
bool

(true)
If true, queues the request during downtime, until connected to Kuzzle again

Return #

Returns the number of matched documents.

Exceptions #

Throws a kuzzleio::KuzzleException if there is an error. See how to handle errors.

Usage #

try {
  int count = kuzzle->document->count("nyc-open-data", "yellow-taxi", R"({
    "query": {
      "match": {
        "license": "valid"
      }
    }
  })");
  std::cout << "Found " << count << " documents matching license:valid" << std::endl;
} catch (kuzzleio::KuzzleException& e) {
  std::cerr << e.what() << std::endl;
}