import #
Creates, updates or deletes large amounts of documents as fast as possible.
This route is faster than the document:m*
routes family (e.g. document:mCreate), but no real-time notifications will be generated, even if some of the documents in the import match subscription filters.
If some documents actions fail, the client will receive a PartialError error.
Query Syntax #
HTTP #
URL: http://kuzzle:7512/<index>/<collection>/_bulk
Method: POST
Body:
{
"bulkData": [
{ "index": {} },
{ "new": "document", "with": "any", "number": "of fields" },
{ "create": {"_id": "foobar"} },
{ "another": "document", "with": "a preset id" },
{ "delete": {"_id": "existing_document_identifier"} },
{ "update": {"_id": "another_document"} },
{ "doc": {"partial": "update"}, "upsert": {"if": "document doesn't exist"} }
]
}
Other protocols #
{
"index": "<index>",
"collection": "<collection>",
"controller": "bulk",
"action": "import",
"body": {
"bulkData": [
{ "index": {} },
{ "new": "document", "with": "any", "number": "of fields" },
{ "create": {"_id": "foobar"} },
{ "another": "document", "with": "a preset id" },
{ "delete": {"_id": "existing_document_identifier"} },
{ "update": {"_id": "another_document"} },
{ "doc": {"partial": "update"}, "upsert": {"if": "document doesn't exist"} }
]
}
}
Arguments #
collection
: collection nameindex
: index name
Body properties #
The body must contain a bulkData
array, detailing the bulk operations to perform, following ElasticSearch Bulk API.
Response #
Returns an object containing 2 properties:
items
: array containing the list of executed queries result, in the same order than in the queryerrors
: boolean indicating if some error occured during the import
Each query result contains the following properties:
_id
: document unique identifierstatus
: HTTP status code for that query.201
(created) or206
(partial error)
{
"status": 200,
"error": null,
"index": "<index>",
"collection": "<collection>",
"controller": "bulk",
"action": "import",
"requestId": "<unique request identifier>",
"result": {
"items": [
{
"create": {
"_id": "<documentId>",
"status": 201
}
},
{
"create": {
"_id": "<documentId>",
"status": 201
}
},
{
"create": {
"_id": "<documentId>",
"status": 201
}
}
]
}
}