SDK
SDK Jvm v1.x
2

write #

Create or replace a document directly into the storage engine.

:::: tabs ::: tab Java

Arguments #

public CompletableFuture<Map<String, Object>> write(
  String index,
  String collection,
  Map<String, Object> content,
  String id,
  Bool notify,
  Bool waitForRefresh
) throws NotConnectedException, InternalException

public CompletableFuture<Map<String, Object>> write(
  String index,
  String collection,
  Map<String, Object> content,
  String id,
  Bool notify
) throws NotConnectedException, InternalException

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

public CompletableFuture<Map<String, Object>> write(
  String index,
  String collection,
  Map<String, Object> content
) throws NotConnectedException, InternalException
ArgumentTypeDescription
index
String
Index name
collection
String
Collection name
content
Map<String, Object>
Document content to create.
id
String

(null)
set the document unique ID to the provided value, instead of auto-generating a random ID
waitForRefresh
Bool

(false)
If set to true, Kuzzle will not respond until the created/replaced documents are indexed
notify
Bool

(false)
If set to true, Kuzzle will trigger realtime notifications

Return #

Return a Map<String, Object> with the following properties:

PropertyTypeDescription
_id
String
Created document unique identifier.
_source
Map<String, Object>
Document content.
_version
Int
Version number of the document

Usage #

Map<String, Object> content = new HashMap<String, Object>();
Map<String, Object> kuzzleInfo = new HashMap<String, Object>();
kuzzleInfo.put("author", "<kuid>");
kuzzleInfo.put("createdAd", "1481816934209");
content.put("_kuzzle_info", kuzzleInfo);
Map<String, Object> result =
kuzzle.getBulkController().write("nyc-open-data", "yellow-taxi", content).get();

::: ::: tab Kotlin

Arguments #

fun write(
  index: String,
  collection: String,
  content: Map<String, Any?>,
  id: String? = null,
  notify: Boolean? = null,
  waitForRefresh: Boolean? = null):
  CompletableFuture<Map<String, Any?>>
ArgumentTypeDescription
index
String
Index name
collection
String
Collection name
content
Map<String, Any?>
Document content to create.

Options #

PropertyTypeDescription
id
String

(null)
set the document unique ID to the provided value, instead of auto-generating a random ID
waitForRefresh
Boolean

(false)
If set to true, Kuzzle will not respond until the created/replaced documents are indexed
notify
Boolean

(false)
If set to true, Kuzzle will trigger realtime notifications

Return #

Return a Map<Strin, Any?> with the following properties:

PropertyTypeDescription
_id
String
Created document unique identifier.
_source
Map<String, Any?>
Document content.
_version
Int
Version number of the document

Usage #

val content: Map<String, Any?> = HashMap<String, Any?>().apply {
  put("_kuzzle_info", HashMap<String, Any?>().apply {
    put("author", "<kuid>")
    put("createdAd", "1481816934209")
  });
}
val result: Map<String, Any?> =
kuzzle.bulkController.write("nyc-open-data", "yellow-taxi", content).get();

::: ::::