create #
Creates a new document in the persistent data storage.
Returns an error if the document already exists.
Query Syntax #
HTTP #
URL: http://kuzzle:7512/<index>/<collection>/_create[?refresh=wait_for][&silent]
URL(2): http://kuzzle:7512/<index>/<collection>/<documentId>/_create[?refresh=wait_for][&silent]
Method: POST
Body:
{
// document content
}
Other protocols #
{
"index": "<index>",
"collection": "<collection>",
"controller": "document",
"action": "create",
"_id": "<documentId>",
"body": {
// document content
}
}
Kourou #
kourou document:create <index> <collection> <body>
kourou document:create <index> <collection> <id> <body>
kourou document:create <index> <collection> <body> -a silent=true
Arguments #
collection
: collection nameindex
: index name
Optional: #
_id
: set the document unique ID to the provided value, instead of auto-generating a random IDrefresh
: if set towait_for
, Kuzzle will not respond until the newly created document is indexedsilent
: if set, then Kuzzle will not generate notificationsAvailable since 2.9.2
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
)
{
"status": 200,
"error": null,
"index": "<index>",
"collection": "<collection>",
"controller": "document",
"action": "create",
"requestId": "<unique request identifier>",
"result": {
"_id": "<documentId>",
"_version": 1,
"_source": {
// ...
},
}
}
Edit this page on Github(opens new window)