Elastic Search Painless scripts returns a warning that a date format using
date.toString('HH')
will be Deprecated.
Following warning:
! Deprecation: 299 Elasticsearch-6.7.0-8453f77 "Use of the joda time method [toString(String)] is deprecated. Use [a DateTimeFormatter] instead."
But when I try to use the Java DateTimeFormatter to format date, I get JodaCompatibleZonedDateTime format not found.
What am I missing here?
getHour()
works, but it is not in the correct format.
doc[params.date_field].date.format(f);
Not working.
doc[params.date_field].value.toString('HH');
Is deprecated.
"aggs": {
"byHour": {
"terms": {
"script": {
"lang": "painless",
"source": """
DateTimeFormatter f = DateTimeFormatter.ofPattern(params.format);
return doc[params.date_field].value.format(f);
""",
"params": {
"date_field": "receivedTime",
"format": "HH"
}
},
"size": 24,
"order": {
"_key": "asc"
}
}
}
}
Error: dynamic method [org.elasticsearch.script.JodaCompatibleZonedDateTime, format/1] not found