Updating a document
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
).
How to do it…
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} ...
Get Lucene 4 Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.