Hello,
I am working with version elasticsearch 6.5.4, I added a new field to my existing index and I want to give it a value equal to the sum of some other fields. I used the following query in Kibana but it does not work, only the first field of the addition operation is recognized :
POST my_index/_update_by_query
{
"script": {
"lang": "painless",
"source": "ctx._source['num_attractivity']=ctx._source['num_comments']+ctx._source['num_comments']"
},
"query": {
"match_all": {}
}
}
######Result :
{
"error": {
"root_cause": [
{
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"ctx._source['num_attractivity']=ctx._source['num_comments']+ctx._source['num_comments']",
" ^---- HERE"
],
"script": "ctx._source['num_attractivity']=ctx._source['num_comments']+ctx._source['num_comments']",
"lang": "painless"
}
],
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"ctx._source['num_attractivity']=ctx._source['num_comments']+ctx._source['num_comments']",
" ^---- HERE"
],
"ctx._source['num_attractivity']=ctx._source['num_comments']+ctx._source['num_comments']",
"lang": "painless",
"caused_by": {
"type": "null_pointer_exception",
"reason": null
}
},
"status": 500
}
#######
thank you.