Updating Documents
Now instead of replacing a document, often times you will want to update it with some new information. Instead of replacing our entire product in order to change the price, we can just… well, change the price! This means that we don’t have to supply all of the fields again, but that we only have to pass in the fields that we want to update. We can do this by issuing a POST request as can be seen below.
POST /ecommerce/product/1001/_update
{
"doc": { "price": "50.00" }
}
Simply nest key-value pairs with a doc property for the fields that you wish to change, along with their new values.
The above request will change the price to 30 and leave the rest of the document’s fields unchanged. If you wish, go to Kibana and verify that the price has indeed been updated, and that the other fields are the same. So this is how you can update certain fields of a document without replacing the entire document, which is quite convenient.
Here is what you will learn:
- The architecture of Elasticsearch
- Mappings and analyzers
- Many kinds of search queries (simple and advanced alike)
- Aggregations, stemming, auto-completion, pagination, filters, fuzzy searches, etc.
- ... and much more!
