SDK
SDK Java 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.

Arguments #

Copied to clipboard!
int count(
  String index,
  String collection,
  String query,
  io.kuzzle.sdk.QueryOptions options
)
int count(
  String index,
  String collection,
  String query
)

Argument Type Description
index
String
Index name
collection
String
Collection name
query
String
A JSON string representing the query to match
options
io.kuzzle.sdk.QueryOptions
The query options.

options #

Additional query options

Option Type
(default)
Description
queuable
boolean

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

Return #

Returns the number of documents matching the given query.

Exceptions #

Throws a io.kuzzle.sdk.KuzzleException if there is an error. See how to handle errors.

Usage #

Copied to clipboard!
try {
  int count = kuzzle.getDocument().count(
    "nyc-open-data",
    "yellow-taxi",
    "{\"query\": {\"match\": {\"license\": \"valid\"}}}"
  );
  System.out.println("Found " + count + " documents matching license:valid");
} catch (KuzzleException e) {
  System.err.println(e.getMessage());
}