write #
Available since 1.8.0
Create or replace a document directly into the storage engine.
This is a low level route intended to bypass Kuzzle actions on document creation, notably:
- check document validity,
- add kuzzle metadata,
- trigger realtime notifications (unless asked otherwise).
Query Syntax #
HTTP #
URL: http://kuzzle:7512/<index>/<collection>/_write[?refresh=wait_for][¬ify][&_id=<document ID>]
Method: POST
Body:
{
// document content
}
Other protocols #
{
"index": "<index>",
"collection": "<collection>",
"controller": "bulk",
"action": "write",
"_id": "<documentId>",
"notify": "<boolean>",
"body": {
// document content
}
}
Arguments #
collection
: data collectionindex
: data index
Optional: #
documentId
: set the document unique ID to the provided value, instead of auto-generating a random IDnotify
: if set to true, Kuzzle will trigger realtime notificationsrefresh
: if set towait_for
, Kuzzle will not respond until the newly created document is indexed
Body properties #
Document content to create.
Response #
Returns an object with the following properties:
_id
: created document unique identifier_source
: document content_version
: version of the created document (should be1
)created
: a boolean telling if a new document has been created
{
"status": 200,
"error": null,
"index": "<index>",
"collection": "<collection>",
"controller": "bulk",
"action": "write",
"requestId": "<unique request identifier>",
"result": {
"_id": "<documentId>",
"_version": 1,
"created": true,
"_source": {
// ...
},
}
}
Edit this page on Github(opens new window)