SDK
SDK Java v3.x
2

This SDK is deprecated. We recommend to use the Kuzzle SDK-JVM.
A migration guide is available here

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 #

public CompletableFuture<Integer> count(
      final String index,
      final String collection)
throws NotConnectedException, InternalException
public CompletableFuture<Integer> count(
      final String index,
      final String collection,
      final ConcurrentHaspMap<String, Object> searchQuery)
throws NotConnectedException, InternalException

ArgumentTypeDescription
index
String
Index name
collection
String
Collection name
searchQuery
ConcurrentHashMap<String, Object>
Query to match

Return #

Returns an Integer.

Usage #

ConcurrentHashMap<String, Object> searchQuery = new ConcurrentHashMap<>();
ConcurrentHashMap<String, Object> match = new ConcurrentHashMap<>();
match.put("Hello", "Clarisse");
searchQuery.put("match", match);
Integer result = kuzzle
  .getDocumentController()
  .count("nyc-open-data", "yellow-taxi", searchQuery)
  .get();