I am using Elasticsearch 7.4, and have a unique requirement to perform below operation in elasticsearch through painless script:-
- Update the field through painless script
- Get the updated value in response
#1 I can perform using painless script using below to update the counter value, but how can I get the updated value in response? I want the new value ctx._source.counter in response of the POST call I made, Is there any way?
curl -XPOST -H "Content-Type:application/json" localhost:9200/myindex/_update_by_query -d "{"query":{"bool":{"filter":[{"match":{"field1":"1"}}]}},"script":{"source":"ctx._source.counter = ctx._source.counter + params.incrementValue","lang":"painless","params":{"incrementValue":"2"}}}"