mCreateOrReplace #
Creates or replaces multiple documents.
The number of documents that can be created or 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>/_mCreateOrReplace[?refresh=wait_for][&silent][&source]
Method: PUT
Body:
{
"documents": [
{
"_id": "<documentId>",
"body": {
// document content
}
},
{
"_id": "<anotherDocumentId>",
"body": {
// document content
}
}
]
}
Other protocols #
{
"index": "<index>",
"collection": "<collection>",
"controller": "document",
"action": "mCreateOrReplace",
"body": {
"documents": [
{
"_id": "<documentId>",
"body": {
// document content
}
},
{
"_id": "<anotherDocumentId>",
"body": {
// document content
}
}
]
}
}
Kourou #
kourou document:mCreateOrReplace <index> <collection> <body>
kourou document:mCreateOrReplace <index> <collection> <body> -a silent=true
Arguments #
collection
: collection nameindex
: index name
Optional: #
refresh
: if set towait_for
, Kuzzle will not respond until the created/replaced documents are indexedsilent
: if set, then Kuzzle will not generate notificationsAvailable since 2.9.2strict
: if set, an error will occur if at least one document has not been created/replacedAvailable since 2.11.0source
: if set, at true, the response will contain the _source field of the created/replaced documents (default true)Available since 2.17.8
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
)created
: a boolean telling whether a document is created (should betrue
)
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": "mCreateOrReplace",
"controller": "document",
"requestId": "<unique request identifier>",
"result": {
"successes": [
{
"_id": "<documentId>",
"_source": {
// document content
},
"_version": 2,
"created": true
},
{
"_id": "<anotherDocumentId>",
"_source": {
// document content
},
"_version": 1,
"created": false
}
],
"errors": [
{
"document": {
// document content
},
"status": 400,
"reason": "Missing document body"
}
]
}
}
Edit this page on Github (opens new window)