Updating your data
In this section, we will discuss different ways of updating existing documents. Internally, an update is always a delete and re-index. You can update using the entire document (replacing the original document), or update a single field or add a new field, or update a field using scripts, such as incrementing a counter.
Update using an entire document
When you index a document with the existing document ID, it will replace the current document with the new document. As shown next, we can update the document ID 1
using the entire document:
PUT chapter4/person/1 { "id": 1, "name": "name update 1", "age": 55, "gender": "M", "email": "[email protected]", "last_modified_date": "2017-02-15" }
The response is as follows:
{ "_index": "chapter4", "_type": "person", "_id": "1", "_version": 2, "result": "updated", "_shards": { "total": 2, "successful": 1, "failed": 0 }, "created": false }
You can see from the response that the result of the...