I. Updating Documents
This example shows how to update we previous document (ID of 1) by changing the name field to "Jane Doe":
Curl-xpost ' 192.168.56.101:9200/customer/external/1/_update?pretty '-d '
{
"Doc": {"name": "Jane Doe"}
}‘
This example shows how to update we previous document (ID of 1) by changing the Name field to ' Jane Doe ' and at the same Time add an age field to it:
Curl-xpost ' 192.168.56.101:9200/customer/external/1/_update?pretty '-d '
{
"Doc": {"name": "Jane Doe", "Ages": 20}
0} '
Elasticsearch support for modifying document information through scripting
Curl-Xpost' 192.168.56.101:9200/customer/external/1/_update?pretty ' -D' {' script ': ' ctx._source.ages + = 5 '} '
OR
Curl-xpost ' 192.168.56.101:9200/customer/external/1/_update?pretty '-d '
{
"Script": {
"Inline": {ctx._source.ages+=age},
"Params": {
"Age": 20
}
}
}‘
In addition to the _source field, CTX can be used to obtain _index, _type, _id, _version, _parent, _timestamp, _ttl, and other field information
You can also use Srcipt to add field information
Curl-xpost ' 192.168.56.101:9200/customer/external/1/_update?pretty '-d '
{
"Script": "Ctx._source.name_of_new_field=\" value_of_new_field\ ""
}‘
You can also use Srcipt to remove field information
Curl-xpost ' 192.168.56.101:9200/customer/external/1/_update?pretty '-d '
{
"Script": "Ctx._source.remove (\" name_of_field\ ")"
}‘
Second, delting Documents
Deleting A document is fairly straightforward. This example shows how to delete our previous customer with the ID of 2
Curl-xdelete ' 192.168.56.101:9200/customer/external/2?pretty '
Third, Batch processing
As a quick example, the following call indexes both documents (ID 1-john Doe and ID 2-jane Doe) in one bulk operation:
Curl-xpost ' Localhost:9200/customer/external/_bulk?pretty '-d ' {"index": {"_id": "1"}}{"name": "John Doe"} {"index": {" _id ":" 2 "}}{" name ":" Jane Doe "} '
This example updates the first document (ID of 1) and then deletes the second document (ID of 2) in one bulk operation:
Curl-xpost ' Localhost:9200/customer/external/_bulk?pretty '-d ' {"Update": {"_id": "1"}}{"Doc": {"name": "John Doe becomes Jane Doe "}} {" Delete ": {" _id ":" 2 "}}
ElasticSearch for Modify your Data