/ Update,
/ Partial,
/ IndexPartial update a document
#
Sometimes we may only need to update a portion of the fields of a document.
A partial update fetches the stored document, merges the partial doc body,
applies the ordered ops operators, and replaces the document in place under
its original _id — the new values are visible to search immediately.
Examples
#
Update the org.id field of the document with system id 0,0 in the
collection my-collection:
.../ Delete,
/ IndexDelete a document
#
Delete a specific document from the specified collection by specifying its unique identifier.
Examples
#
Delete the document 0,0 from collection my-collection:
DELETE /my-collection/_doc/0,0
The API returns the following result:
{
"_id": "0,0",
"_version": 0,
"result": "deleted",
...
}
Deleting a document again (or fetching it after deletion) answers
404 with "result": "not_found" — the delete itself still succeeds
and reports "result": "deleted" only for a document that was live.
.../ Bulk,
/ IndexBatch document operation
#
Provides a efficient way to perform multiple index, create, delete, and update
operations in a single request.
Examples
#
POST /_bulk
{ "index" : { "_index" : "test", "_id" : "1" } }
{ "field1" : "value1" }
{ "delete" : { "_index" : "test", "_id" : "2" } }
{ "create" : { "_index" : "test", "_id" : "3" } }
{ "field1" : "value3" }
{ "update" : {"_id" : "1", "_index" : "test"} }
{ "doc" : {"field2" : "value2"} }
The API returns the following result:
{
"took": 30,
"errors": false,
"items": [
{
"index": {
"_collection": "default:test",
"_id": "0,0",
"result": "created",
...
}
},
{
"delete": {
"_collection": "default:test",
"_id": "0,1",
"result": "not_found",
...
}
},
{
"create": {
"_collection": "default:test",
"_id": "0,2",
"result": "created",
...
}
},
{
"update": {
"_collection": "default:test",
"_id": "0,0",
"result": "updated",
...
}
}
]
}
Request
#
POST /_bulk
POST /<target>/_bulk
Path parameters
#
<target>
(Optional, string) Name of the collection to target. Actions that don’t
explicitly specify their target in the action line use it.
Query parameters
#
realtime
(Optional, boolean, default: true) Request-level write-mode switch that
overrides schema property-level realtime settings for every document in
this request: false applies the batch WAL-only (durable immediately,
searchable after the offline epoch build).key_as_id
(Optional, boolean, default: false) compatibility rendering: keyed
documents answer with the user key AS _id (see the index API).sync_replication
(Optional, boolean) Opt back into synchronous inline replication for
this request (wait for the replica RPC and count it in the response).
Request body
#
The actions are specified in the request body using a newline delimited JSON
(NDJSON) structure:
...