SDK
SDK Jvm v1.x
2

updateByQuery #

Updates documents matching the provided search query.

Kuzzle uses the ElasticSearch Query DSL syntax.

:::: tabs ::: tab Java

Arguments #

Copied to clipboard!
public CompletableFuture<Int> updateByQuery(
  String index,
  String collection,
  Map<String, Any?> searchQuery,
  Map<String, Any?> changes,
  Boolean waitForRefresh
) throws NotConnectedException, InternalException

public CompletableFuture<Int> updateByQuery(
  String index,
  String collection,
  Map<String, Any?> searchQuery,
  Map<String, Any?> changes,
) throws NotConnectedException, InternalException

Argument Type Description
index
String
Index name
collection
String
Collection name
searchQuery
Map<String, Any?>
JSON representing the query to match
changes
Map<String, Any?>
JSON representing the changes to apply
waitForRefresh
Bool

(false)
If set to true, Kuzzle will not respond until the delete documents are indexed

Return #

An Int containing the number of updated documents.

Usage #

Copied to clipboard!
Map<String, Object> term = new HashMap<String, Object>();
term.put("capacity", 7);
Map<String, Object> searchQuery = new HashMap<String, Object>();
searchQuery.put("query", term);
Map<String, Object> changes = new HashMap<String, Object>();
changes.put("capacity", 3);
searchQuery.put("changes", changes);
Integer result = kuzzle.getBulkController().updateByQuery("nyc-open-data", "yellow-taxi", searchQuery, changes).get();

::: ::: tab Kotlin

Arguments #

Copied to clipboard!
fun updateByQuery(
  index: String,
  collection: String,
  searchQuery: Map<String, Any?>,
  waitForRefresh: Boolean? = null
): CompletableFuture<Int>

Argument Type Description
index
String
Index name
collection
String
Collection name
searchQuery
Map<String, Any?>
JSON representing the query to match
changes
Map<String, Any?>
JSON representing the changes to apply
waitForRefresh
Boolean

(false)
If set to true, Kuzzle will not respond until the delete documents are indexed

Return #

An Int containing the number of updated documents.

Usage #

Copied to clipboard!
val searchQuery: Map<String, Any?> = HashMap<String, Any?>().apply {
  put("query", HashMap<String, Any?>().apply {
    put("term", HashMap<String, Any?>().apply {
      put("capacity", 7)
    })
  })
}
val changes: Map<String, Any?> = HashMap<String, Any?>().apply {
  put("changes", HashMap<String, Any?>().apply {
    put("capacity", 3)
  })
}
val result: Int = kuzzle.bulkController.updateByQuery("nyc-open-data", "yellow-taxi", searchQuery, changes).get()

::: ::::