I wrote this script using groovy language (datediff.groovy
):
(doc[secondDateField].date.millis - doc[firstDateField].date.millis) / 3600000
It works fine. Nevertheless, I'm intended to move these script to painless
(datediff.painless
). Nevertheless, I'm getting compilation error on straup:
[esn1] failed to load/compile script [datediff]: {
"type" : "script_exception",
"reason" : "compile error",
"caused_by" : {
"type" : "illegal_argument_exception",
"reason" : "Variable [secondDateField] is not defined."
},
"script_stack" : [
"(doc[secondDateField].date.mil ...",
" ^---- HERE"
],
"script" : "(doc[secondDateField].date.millis - doc[firstDateField].date.millis) / 3600000",
"lang" : "painless"
}
It's telling me secondDateField
is not defined. Could you help me in order to get it?