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]
URL(2): http://kuzzle:7512/<index>/<collection>/<documentId>/_create[?refresh=wait_for]
Method: POST
Body:
{
// document content
}
Other protocols
{
"index": "<index>",
"collection": "<collection>",
"controller": "document",
"action": "create",
"_id": "<documentId>",
"body": {
// document content
}
}
Arguments
collection
: collection nameindex
: index name
Optional:
documentId
: 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 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
)
{
"status": 200,
"error": null,
"index": "<index>",
"collection": "<collection>",
"controller": "document",
"action": "create",
"requestId": "<unique request identifier>",
"result": {
"_id": "<documentId>",
"_version": 1,
"_source": {
// ...
},
}
}