Using script to generate data and using a doc variable, it generates the error "doc [column] is not defined".
This error occurs in ElasticSearch 6.2.4 (production environment), when I use 6.2.3 in Docker (developer environment) this error does not happen.
I checked the index mapping and the column is in it.
How i can solve the problem?
Edit
Checking the local script against the remote, I noticed that the remote removed the quotation marks between the doc [].
Could that be the problem?
curl 'http://localhost:9200/_scripts/deadline'
{"_id":"deadline","found":true,"script":{"lang":"painless","source":"if ( (doc[deadline].empty) && (doc[deadline_reply_counter].empty) ) { /*NÃO POSSUI*/ return 2; }"}}
This is the cURL to create the script:
curl -X POST "localhost:9200/_scripts/deadline" -H 'Content-Type: application/json' -d'
{
"script": {
"lang": "painless",
"source": "if ( (doc['deadline'].empty) && (doc['deadline_reply_counter'].empty) ) { return 2; } "
}
}
'
This is the query:
{
"query":{
"bool":{
"must":[
{
"term":{
"censored_column":1234
}
}
]
}
},
"_source":[
],
"script_fields":{
"deadline_ok":{
"script":{
"id":"deadline",
"params":{
"current_timestamp":1526476514389
}
}
},
"start_deadline_ok":{
"script":{
"id":"start_deadline",
"params":{
"current_timestamp":1526476514389
}
}
}
},
"sort":{
"censored_column_2":{
"order":"asc"
}
}
}
This is the error:
"lang":"painless","caused_by":{"type":"illegal_argument_exception","reason":"Variable [deadline] is not defined."}}}]}