mWrite #
Create or replace multiple documents directly into the storage engine.
This is a low level route intended to bypass Kuzzle actions on document creation, notably:
- check document write limit Available since 2.3.3
- check document validity,
- add kuzzle metadata,
- trigger realtime notifications (unless asked otherwise)
Query Syntax #
HTTP #
URL: http://kuzzle:7512/<index>/<collection>/_mWrite[?refresh=wait_for][¬ify]
Method: POST
Body:
{
"documents": [
{
"_id": "<documentId>",
"body": {
// document content
}
},
{
"_id": "<anotherDocumentId>",
"body": {
// document content
}
}
]
}
Other protocols #
{
"index": "<index>",
"collection": "<collection>",
"controller": "bulk",
"action": "mWrite",
"notify": "<boolean>",
"body": {
"documents": [
{
"_id": "<documentId>",
"body": {
// document content
}
},
{
"_id": "<anotherDocumentId>",
"body": {
// document content
}
}
]
}
}
Arguments #
collection
: data collectionindex
: data index
Optional: #
notify
: if set to true, Kuzzle will trigger realtime notificationsrefresh
: if set towait_for
, Kuzzle will not respond until the created/replaced documents are indexedstrict
: if set, an error will occur if at least one document has not been created/replacedAvailable since 2.11.0
Body properties #
documents
: an array of object. Each object describes a document to create or replace, by exposing the following properties:_id
: document unique identifierbody
: document content
Response #
Returns an object containing 2 arrays: successes
and errors
Each created or replaced document is an object of the successes
array with the following properties:
_id
: document unique identifier_source
: document content_version
: version of the document (should be1
)
Each errored document is an object of the errors
array with the following properties:
document
: original document that caused the errorstatus
: HTTP error status codereason
: human readable reason
If strict
mode is enabled, will rather return an error if at least one document has not been created/replaced.
Example #
{
"status": 200,
"error": null,
"index": "<index>",
"collection": "<collection>",
"action": "mWrite",
"controller": "bulk",
"requestId": "<unique request identifier>",
"result": {
"successes": [
{
"_id": "<documentId>",
"_source": {
// document content
},
"_version": 2
},
{
"_id": "<anotherDocumentId>",
"_source": {
// document content
},
"_version": 1
}
],
"errors": []
}
}
Edit this page on Github(opens new window)