The updated API allows you to add/update fields in a document. The action can be triggered by using the HTTP PUT or POST method. A document can be specified by their ids (_id field
).
Let's assume that we have an existing document in our news article index, in which id is 1 and title is "Europe stocks tumble on political fears, PMI data"
. We will submit an update action to update title to "Europe stocks tumble on political fears, PMI data | STOCK NEWS"
.
Here is a PUT method example:
curl -XPUT 'http://localhost:9200/news/article/1' -d ' { "title" : "Europe stocks tumble on political fears, PMI data | STOCK NEWS" }'
If successful, it should return the following:
{"_index":"news","_type":"article","_id":"1","_version":2,"created":false}
Here is a POST
method example:
curl -XPOST 'http://localhost:9200/news/article/1/_update' -d ' { "doc" : { "title" : "Europe stocks tumble on political fears, PMI data | STOCK NEWS" } }'
If successful, it should return the...