SDK
SDK Jvm v1.x
2

mWrite #

This is a low level route intended to bypass Kuzzle actions on document creation, notably:

:::: tabs ::: tab Java

Arguments #

public CompletableFuture<Map<String, Object>> importData (
  String index,
  String collection,
  ArrayList<Map<String, Object>> bulkData
) throws NotConnectedException, InternalException
ArgumentTypeDescription
index
String
Index name
collection
String
Collection name
documents
ArrayList<Map<String, Object>>
An array of JObject representing the documents

documents #

An array of Map<String, Object>. Each object describes a document to create or replace, by exposing the following properties:

  • _id: document unique identifier (optional)
  • body: document content

Options #

PropertyTypeDescription
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 #

Returns a Map<String, Object> containing 2 arrays: successes and errors

Each created or replaced document is an object of the successes array with the following properties:

NameTypeDescription
_id
String
Document ID
_version
Integer
Version of the document in the persistent data storage
_source
Map<String, Object>
Document content
created
Bool
True if the document was created

Each errored document is an object of the errors array with the following properties:

NameTypeDescription
document
Map<String, Object>
Document that cause the error
status
Integer
HTTP error status
reason
String
Human readable reason

Usage #

Map<String, Object> document = new HashMap<String, Object>();
ArrayList<Map<String, Object>> documents = new ArrayList<Map<String, Object>>();
documents.add(document);
document.put("_id", "foo");
document.put("body", new HashMap<String, Object>());
Map<String, Object> result =
kuzzle.getBulkController().mWrite("nyc-open-data", "yellow-taxi", documents).get();

::: ::: tab Kotlin

Arguments #

fun importData(
  index: String,
  collection: String,
  bulkData: ArrayList<Map<String, Any?>>
): CompletableFuture<Map<String, Any?>>
ArgumentTypeDescription
index
String
Index name
collection
String
Collection name
documents
ArrayList<Map<String, Any?>>
An array of JObject representing the documents

documents #

An array of Map<String, Any?>. Each object describes a document to create or replace, by exposing the following properties:

  • _id: document unique identifier (optional)
  • body: document content

Options #

PropertyTypeDescription
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 #

Returns a Map<String, Object> containing 2 arrays: successes and errors

Each created or replaced document is an object of the successes array with the following properties:

NameTypeDescription
_id
String
Document ID
_version
Int
Version of the document in the persistent data storage
_source
<Map<String, Any?>
Document content
created
Bool
True if the document was created

Each errored document is an object of the errors array with the following properties:

NameTypeDescription
document
Map<String, Any?>
Document that cause the error
status
Int
HTTP error status
reason
String
Human readable reason

Usage #

val documents: ArrayList<Map<String, Any?>> = ArrayList<Map<String, Any?>>().apply {
  add(HashMap<String, Any?>().apply {
    put("_id", "foo")
    put("body", HashMap<String, Any?>())
  })
};
val result: Map<String, Any?> = 
kuzzle.bulkController.mWrite("nyc-open-data", "yellow-taxi", documents).get();

::: ::::