SDK
SDK Jvm v1.x
2

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.

:::: tabs ::: tab Java

Arguments #

Copied to clipboard!
public CompletableFuture<Integer> count(
      String index,
      String collection)
throws NotConnectedException, InternalException

public CompletableFuture<Integer> count(
      String index,
      String collection,
      ConcurrentHaspMap<String, Object> searchQuery)
throws NotConnectedException, InternalException
Argument Type Description
index
String
Index name
collection
String
Collection name
searchQuery
Map<String, Object>

({})
Query to match

Return #

Returns an Integer.

Usage #

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

::: ::: tab Kotlin

Arguments #

Copied to clipboard!
fun count(
      index: String,
      collection: String,
      searchQuery: Map<String, Any?> = HashMap<String, Any?>()): CompletableFuture<Int>
Argument Type Description
index
String
Index name
collection
String
Collection name
searchQuery
Map<String, Any?>

({})
Query to match

Return #

Returns an Integer.

Usage #

Copied to clipboard!
val searchQuery : Map<String, Any?> =
  HashMap<String, Any?>().apply {
    put("match", HashMap<String, Any?>().apply {
      put("Hello", "Clarisse")
    })
  }
val result: Int = kuzzle
  .documentController
  .count("nyc-open-data", "yellow-taxi", searchQuery)
  .get()

::: ::::