mReplace #
Replaces multiple documents.
The number of documents that can be replaced by a single request is limited by the documentsWriteCount
server configuration (see the Configuring Kuzzle guide).
Query Syntax #
HTTP #
URL: http://kuzzle:7512/<index>/<collection>/_mReplace[?refresh=wait_for][&silent]
Method: PUT
Body:
{
"documents": [
{
"_id": "<documentId>",
"body": {
// new document content
}
},
{
"_id": "<anotherDocumentId>",
"body": {
// new document content
}
}
]
}
Other protocols #
{
"index": "<index>",
"collection": "<collection>",
"controller": "document",
"action": "mReplace",
"body": {
"documents": [
{
"_id": "<documentId>",
"body": {
// new document content
}
},
{
"_id": "<anotherDocumentId>",
"body": {
// new document content
}
}
]
}
}
Kourou #
kourou document:mReplace <index> <collection> <body>
kourou document:mReplace <index> <collection> <body> -a silent=true
Arguments #
collection
: collection nameindex
: index name
Optional: #
refresh
: if set towait_for
, Kuzzle will not respond until the replacements are indexedstrict
: if set, an error will occur if at least one document has not been replacedAvailable since 2.11.0silent
: if set, then Kuzzle will not generate notificationsAvailable since 2.9.2
Body properties #
documents
: an array of object. Each object describes a document to replace, by exposing the following properties:_id
: ID of the document to replacebody
: document content
Response #
Returns an object containing 2 arrays: successes
and errors
Each 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
Errored documents are not guaranteed to be in the same orded as in the initial request.
If strict
mode is enabled, will rather return an error if at least one document has not been replaced.
{
"status": 200,
"error": null,
"index": "<index>",
"collection": "<collection>",
"action": "mReplace",
"controller": "document",
"requestId": "<unique request identifier>",
"result": {
"successes": [
{
"_id": "<documentId>",
"_source": {
// new document content
},
"_version": 2
},
{
"_id": "<anotherDocumentId>",
"_source": {
// new document content
},
"_version": 4
}
],
"errors": [
{
"document": {
// new document content
},
"status": 404,
"reason": "Document 'foobar' not found"
}
]
}
}
Edit this page on Github (opens new window)