curl -XPOST 'localhost:9200/customer/external/1/_update?pretty' -d '
{
"script" : "ctx._source.age += 5"
}'
This an example on official site. I am confused with ctx, what does it mean? Context?
the ctx. payload field contains the response of the search request you executed in your input. If you execute a HTTP request against any service, this payload will change according to the response.
ctx['op'] Use the default of index to update a document. Set to none to specify no operation or delete to delete the current document from the index. ctx['_source'] Modify the values in the Map/List structure to add, modify, or delete the fields of a document.
DescriptioneditEnables you to script document updates. The script can update, delete, or skip modifying the document. The update API also supports passing a partial document, which is merged into the existing document. To fully replace an existing document, use the index API.
Painless is a simple, secure scripting language designed specifically for use with Elasticsearch. It is the default scripting language for Elasticsearch and can safely be used for inline and stored scripts.
ctx
is a special variable that allows you to access the source of the object that you want to update. The ctx._source
is a writable version of the source
.
NOTE: You can modify this document in the script and the modified source will be persisted as the new version of the document.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With