Hi, I'm trying to add two new fields to a document: all2_business_index.car, car being an array. The code below throws a null_pointer_exception
How canI fix this, thank you
Blockquote
"script_stack": [
"ctx._source.all2_business_index.car = []\r\n ;",
" ^---- HERE"
],
Blockquote
POST test_kris_assignment/_update_by_query
{
"query": {
"term": {
"per_id": "10040298"
}
},
"script": {
"lang": "painless",
"source" : """if (ctx._source.car.current_assignment[0].job_description[0].jdl1_id != null && ctx._source.car.current_assignment[0].job_description[0].jdl2_id != null && ctx._source.car.current_assignment[0].job_description[0].jdl3_id != null)
{def a = [ "domain_type" : ["jdl_id": ctx._source.car.current_assignment[0].job_description[0].jdl1_id, "jdl_descr": ctx._source.car.current_assignment[0].job_description[0].jdl1_descr] ]
;def scores = [a]
;ctx._source.all2_business_index = null
;ctx._source.all2_business_index.car = []
;for (int i = 0; i < scores.length; i++) { ctx._source.all2_business_index.car.add(scores[i])}
ctx.op = 'index' }
else { ctx.op = 'noop'}"""
}
}