Day of Week aggregation with TimeZone

I use ES 5.1.2 and I'm trying to compute day of week and time of day from a date field and consider timezone at the same time.

my first script is def d = doc['my_field'].date; d.addHours(10); d.getDayOfWeek();

The error message is can't find addHours() method

"caused_by": {
    "type": "illegal_argument_exception",
    "reason": "Unable to find dynamic method [addHours] with [1] arguments for class [org.joda.time.MutableDateTime]."
},
"script_stack": [
    "d.addHours(10); ",
    " ^---- HERE"
],

If I change script to MutableDateTime d = doc['my_field'].date; d.addHours(10); d.getDayOfWeek(); The error message becomes

"caused_by": {
  "type": "illegal_argument_exception",
  "reason": "unexpected token ['d'] was expecting one of [{<EOF>, ';'}]."
},
"script_stack": [
  "MutableDateTime d = doc['relation_denstu. ...",
  "                ^---- HERE"
],

Without addHours to adjust timezone, everything is fine. But if I try to adjust timezone dynamically, everything failed. Any help?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.