Hi, I've created a watch containing transform for which I get a runtime error when executing:
"type" : "illegal_argument_exception",
"reason" : "dynamic method [java.lang.String, getMillis/0] not found"
"script_stack" : [ "tmpdate = Instant.ofEpochMilli(ctx.payload.hits.hits[j]._source.eventTime.getMillis()).atZone(ZoneId.of('Europe/Zagreb')).format(DateTimeFormatter.ofPattern('YYYY-MM-dd HH:mm:ss')); ", " ^---- HERE" ],
The whole transform is here (I've break the lines for easier readibility):
"transform":{ "script": { "suorce": " ctx.payload.transform = []; def document = []; for (int j=0;j<ctx.payload.hits.hits;j++) { def tmpdate = Instant.ofEpochMilli(ctx.payload.hits.hits[j]._source.eventTime.getMillis()).atZone(ZoneId.of('Europe/Zagreb')).format(DateTimeFormatter.ofPattern('YYYY-MM-dd HH:mm:ss'));; document = [ 'amount': ctx.payload.hits.hits[j]._source.amount, 'eventTime': tmpdate ]; ctx.payload.transform.add(document) } return ['totalCnt': ctx.payload.hits.total, 'transformedHits': ctx.payload.transform];", "lang": "painless" } }
Any help to get me on the right line is appreciated.
EDIT:
Maping for field eventTime is:
"eventTime": { "type": "date" }
EDIT2:
Watcher executes and returns this document inside hits:
"hits" : { "hits" : [ { "_index" : "my_requests", "_type" : "_doc", "_source" : { "amount" : 1200.0, "eventTime" : "2019-07-23T12:40:26.9739999Z", "@version" : "1", "status" : "0" }, "_id" : "bb64b6af3c374cfb9ae2ec107ec2310d", "sort" : [ 1563885626973 ], "_score" : null }, ...