SDK
SDK Jvm v1.x
2

update #

Updates a document.


:::: tabs ::: tab Java

Arguments #

Copied to clipboard!
public CompletableFuture<Map<String, Object>> update(
      String index,
      String collection,
      String id,
      Map<String, Object> document,
      Boolean waitForRefresh,
      Integer retryOnConflict,
      Boolean source)
throws NotConnectedException, InternalException

public CompletableFuture<Map<String, Object>> update(
      String index,
      String collection,
      String id,
      Map<String, Object> document,
      Boolean waitForRefresh,
      Integer retryOnConflict)
throws NotConnectedException, InternalException

public CompletableFuture<Map<String, Object>> update(
      String index,
      String collection,
      String id,
      Map<String, Object> document,
      Boolean waitForRefresh)
throws NotConnectedException, InternalException

public CompletableFuture<Map<String, Object>> update(
      String index,
      String collection,
      String id,
      Map<String, Object> document)
throws NotConnectedException, InternalException
Arguments Type Description
index
String
Index
collection
String
Collection
id
String
Document ID
document
Map<String, Object>
Partial document content
waitForRefresh
Boolean
If set to true, Kuzzle will wait for the persistence layer to finish indexing
retryOnConflict
Integer
The number of times the database layer should retry in case of version conflict
source
Boolean
If true, returns the updated document inside the response

Return #

A Map which has the following properties:

Property Type Description
_source
Map
Updated document (If source option set to true)
_id
String
ID of the updated document
_version
Integer
Version of the document in the persistent data storage

Usage #

Copied to clipboard!
  Map<String, Object> content = new HashMap<>();
  content.put("name", "Johny");
  Map<String, Object> result =
  kuzzle.getDocumentController().update("nyc-open-data", "yellow-taxi", "some-id", content)
  .get();
/*
  response =
  {
    _id=some-id,
    _version=2
  }
*/

::: ::: tab Kotlin

Arguments #

Copied to clipboard!
  fun update(
      index: String,
      collection: String,
      id: String?,
      document: Map<String?, Any?>?,
      waitForRefresh: Boolean? = null,
      retryOnConflict: Int? = null,
      source: Boolean? = null): CompletableFuture<Map<String, Any?>>
Arguments Type Description
index
String
Index
collection
String
Collection
id
String
Document ID
document
Map<String, Any?>
Partial document content
waitForRefresh
Boolean
If set to true, Kuzzle will wait for the persistence layer to finish indexing
retryOnConflict
Int
The number of times the database layer should retry in case of version conflict
source
Boolean
If true, returns the updated document inside the response

Return #

A Map which has the following properties:

Property Type Description
_source
Map
Updated document (If source option set to true)
_id
String
ID of the updated document
_version
Int
Version of the document in the persistent data storage

Usage #

Copied to clipboard!
val document: Map<String, Any?> =
  HashMap<String, Any?>().apply {
    put("name", "Johny")
  }
val result: Map<String, Any?> =
  kuzzle
  .documentController
  .update("nyc-open-data", "yellow-taxi", "some-id", document)
  .get()

::: ::::