# running ok
POST products/_update_by_query
{
"script": {
"source": "ctx._source.in_stock++",
"lang": "painless"
},
"query": {
"term": {
"name": "LED TV"
}
}
}
# running ok
POST products/_search
{
"query": {
"match_all": {}
}
}
# running error
POST products/_update_by_query
{
"script": {
"source": "ctx._source.in_stock++",
"lang": "painless"
},
"query": {
"match_all": {}
}
}
The errors as below:
{
"error": {
"root_cause": [
{
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"ctx._source.in_stock++",
"^---- HERE"
],
"script": "ctx._source.in_stock++",
"lang": "painless"
}
],
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"ctx._source.in_stock++",
"^---- HERE"
],
"script": "ctx._source.in_stock++",
"lang": "painless",
"caused_by": {
"type": "null_pointer_exception",
"reason": null
}
},
"status": 400
}