mUpdate #
Updates multiple documents.
:::: tabs ::: tab Java
Arguments #
public CompletableFuture<ConcurrentHashMap<String, ArrayList<Object>>> mUpdate(
String index,
String collection,
ArrayList<ConcurrentHashMap<String, Object>> documents) throws NotConnectedException, InternalException
public CompletableFuture<ConcurrentHashMap<String, ArrayList<Object>>> mUpdate(
String index,
String collection,
ArrayList<ConcurrentHashMap<String, Object>> documents,
Boolean waitForRefresh) throws NotConnectedException, InternalException
public CompletableFuture<ConcurrentHashMap<String, ArrayList<Object>>> mUpdate(
String index,
String collection,
ArrayList<ConcurrentHashMap<String, Object>> documents,
Boolean waitForRefresh,
Integer retryOnConflict) throws NotConnectedException, InternalException
Arguments | Type | Description |
---|---|---|
index | String | Index |
collection | String | Collection |
documents | ArrayList<Map<String, Object>> | ArrayList containing the documents to update |
retryOnConflict | Integer(optional) | The number of times the database layer should retry in case of version conflict |
waitForRefresh | Boolean(optional) | If set to true , Kuzzle will wait for the persistence layer to finish indexing |
documents #
Each document has the following properties:
Arguments | Type | Description |
---|---|---|
_id | String | Document ID |
body | Map<String, Object> | Document body |
Return #
A Map<String, ArrayList<Object>>
which has a successes
and errors
ArrayList<Object>
: Each created document is an object of the successes
array with the following properties:
Property | Type | Description |
---|---|---|
_source | Map<String, Object> | Updated document |
_id | String | ID of the updated document |
_version | Integer | Version of the document in the persistent data storage |
Each errored document is an object of the errors
array with the following properties:
Property | Type | Description |
---|---|---|
document | Map<String, Object> | Document that causes the error |
status | Integer | HTTP error status |
reason | String | Human readable reason |
Usage #
Map<String, Object> document1 = new HashMap<>();
Map<String, Object> document2 = new HashMap<>();
Map<String, Object> body = new HashMap<>();
Map<String, Object> body2 = new HashMap<>();
body.put("name", "Smith");
body2.put("name", "Freeman");
document1.put("_id", "some-id");
document1.put("body", body);
document2.put("_id", "some-id2");
document2.put("body", body2);
final ArrayList<Map<String, Object>> documents = new ArrayList<>();
documents.add(document1);
documents.add(document2);
Map<String, ArrayList<Object>> result = kuzzle
.getDocumentController()
.mUpdate("nyc-open-data", "yellow-taxi", documents)
.get();
/*
result =
{
successes=
[
{
result=created,
_source=
{
Agent=Smith,
_kuzzle_info={createdAt=1582892842099, author=-1}
},
_id=some-id,
_version=1,
status=200
},
{
result=created,
_source=
{
Gordon=Freeman,
_kuzzle_info={createdAt=1582892842099, author=-1}
},
_id=some-id2,
_version=1,
status=200
}
],
errors=[]
}
*/
::: ::: tab Kotlin
Arguments #
fun mUpdate(
index: String,
collection: String,
documents: ArrayList<Map<String, Any?>?>,
waitForRefresh: Boolean? = null,
retryOnConflict: Int? = null): CompletableFuture<Map<String, ArrayList<Any>?>>
Arguments | Type | Description |
---|---|---|
index | String | Index |
collection | String | Collection |
documents | ArrayList<Map<String, Any?>> | ArrayList containing the documents to update |
retryOnConflict | Int(optional) | The number of times the database layer should retry in case of version conflict |
waitForRefresh | Boolean(optional) | If set to true , Kuzzle will wait for the persistence layer to finish indexing |
documents #
Each document has the following properties:
Arguments | Type | Description |
---|---|---|
_id | String | Document ID |
body | Map<String, Any?> | Document body |
Return #
A Map<String, ArrayList<Any?>>
which has a successes
and errors
ArrayList<Any?>
: Each created document is an object of the successes
array with the following properties:
Property | Type | Description |
---|---|---|
_source | Map<String, Any?> | Updated document |
_id | String | ID of the updated document |
_version | Int | Version of the document in the persistent data storage |
Each errored document is an object of the errors
array with the following properties:
Property | Type | Description |
---|---|---|
document | Map<String, Any?> | Document that causes the error |
status | Int | HTTP error status |
reason | String | Human readable reason |
Usage #
val document1: Map<String, Any?> =
HashMap<String, Any?>().apply {
put("_id", "some-id")
put("body", HashMap<String, Any?>().apply {
put("name", "Smith")
})
}
val document2: Map<String, Any?> =
HashMap<String, Any?>().apply {
put("_id", "some-id2")
put("body", HashMap<String, Any?>().apply {
put("name", "Freeman")
})
}
val documents: ArrayList<Map<String, Any?>> =
ArrayList<Map<String, Any?>>().apply {
add(document1)
add(document2)
}
val result: Map<String, ArrayList<Any>?> =
kuzzle
.documentController
.mReplace("nyc-open-data", "yellow-taxi", documents)
.get()
::: ::::
Edit this page on Github(opens new window)