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 #
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 #
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());
}
Edit this page on Github(opens new window)