Replace a document #
Replace an existing document by specifying its unique identifier and the new content.
Examples #
Replace a document news_001
of the collection my-collection
with new content:
PUT /my-collection/_doc/news_001
{
"message": "GET /search HTTP/1.1 200 1070000",
"org": {
"id": "infinilabs"
}
}
The API returns as following result:
{"_id":"0,0", "_key":"news_001", "result":"updated"}
After the document modification, If you perform the fetch request:
GET /my-collection/_doc/news_001
It returns an updated document like:
{
"_id": "0,0",
"_version": 2,
"_namespace": "default",
"_collection": "my-collection",
"_key" : "news_001",
"found": true,
"_source" : {
"message": "GET /search HTTP/1.1 200 1070000",
"org": {
"id": "infinilabs"
}
}
}
Note that the document _version
was increased to 2
.
Pizza works by marking the old document as deleted and insert a new document under the hood.
Request #
POST /<target>/_doc/<doc_id>
{<fields>}
Path parameters #
<target>
(Required, string) Name of the collection to target.<doc_id>
(Required, string) The unique identify of this document, support both_key
or_id
.
Request body #
<fields>
(Required, string) Request body contains the JSON source for the document data.