Replace a document
/ Replace, / IndexReplace 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:
{
"_collection": "default:my-collection",
"_id": "0,0",
"_key" : "news_001",
"found": true,
"source" : {
"message": "GET /search HTTP/1.1 200 1070000",
"org": {
"id": "infinilabs"
}
}
}
The replacement happens in place: the document keeps its original _id, and the
index entries of the old version are rebuilt under the same _id. Since this is
a full replacement, fields that are omitted from the request body are cleared.