Hello everyone,
I'm building a painless script for a scripted field, but when I do a check for null using size() (the validation method recommended for Kibana 7.1.0), I'm getting exception error:
Request to Elasticsearch failed: {"error":{"root_cause":[{"type":"script_exception","reason":"compile error","script_stack":["... , retorna null\n return null;\n}"," ^---- HERE"],"script":"if (doc['obrigacao_prazo_cumprimento'].size() == 0){ // Se não houver prazo, retorna null\n return null;\n}","lang":"painless"}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"vv_106_tarefas","node":"EqfbZ7UtS8aorpsDs5pF_A","reason":{"type":"script_exception","reason":"compile error","script_stack":["... , retorna null\n return null;\n}"," ^---- HERE"],"script":"if (doc['obrigacao_prazo_cumprimento'].size() == 0){ // Se não houver prazo, retorna null\n return null;\n}","lang":"painless","caused_by":{"type":"illegal_argument_exception","reason":"Cannot cast null to a primitive type [double]."}}}]},"status":400}
This is the script:
if (doc['obrigacao_prazo_cumprimento'].size() == 0){
return null;
}
There is more on the script, but this line is the first one and is breaking.
The field is a date and returns a number.
Can someone help me solve this?
Thanks