SDK
SDK Jvm v1.x
2

replace #

Replaces the content of an existing document.


:::: tabs ::: tab Java

Arguments #

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

public CompletableFuture<Map<String, Object>> replace(
      String index,
      String collection,
      String id,
      Map<String, Object> document,
      Boolean waitForRefresh)
throws NotConnectedException, InternalException
ArgumentsTypeDescription
index
String
Index
collection
String
Collection
id
String
Document ID
document
Map<String, Object>
New content of the document to update
waitForRefresh
Boolean
If set to true, Kuzzle will wait for the persistence layer to finish indexing

Return #

A Map which has the following properties:

PropertyTypeDescription
_source
Map
Document content
_id
String
ID of the document
_version
Integer
Version of the document in the persistent data storage

Usage #

Map<String, Object> document = new HashMap<>();
document.put("firstname", "John");
Map<String, Object> result = kuzzle.getDocumentController().replace("nyc-open-data", "yellow-taxi", "some-id", document)
.get();
/*
result =
  {
    _source=
      {
        firstname=John,
        _kuzzle_info={ createdAt=1582892606555, author=-1, updatedAt=1582892606555, updater=-1 }
      },
    _id=some-id,
    _version=2
  }
 */

::: ::: tab Kotlin

Arguments #

fun replace(
      index: String,
      collection: String,
      id: String?,
      document: Map<String, Any?>,
      waitForRefresh: Boolean? = null): CompletableFuture<Map<String, Any?>>
ArgumentsTypeDescription
index
String
Index
collection
String
Collection
id
String
Document ID
document
Map<String, Any?>
New content of the document to update
waitForRefresh
Boolean
If set to true, Kuzzle will wait for the persistence layer to finish indexing

Return #

A Map which has the following properties:

PropertyTypeDescription
_source
Map
Document content
_id
String
ID of the document
_version
Int
Version of the document in the persistent data storage

Usage #

val document: Map<String, Any?> =
  HashMap<String, Any?>().apply {
    put("firstname", "John")
  }
val result: Map<String, Any?> =
  kuzzle
  .documentController
  .replace("nyc-open-data", "yellow-taxi", "some-id", document)
  .get()

::: ::::