the initial idea is correct. However ctx.payload.hits.hits[0]._source['@timestamp'] is not of type datetime but just a string, thus the comparison fails. You need to convert that one also into an Instant. You can try to use Instant.parse() for that.
Thanks for the swift reply.
My date is in the format
2018-01-17T11:10:42.217+00:00
As opposed to the expected
2018-01-17T11:10:42.217Z
I get the following error:
{
"type": "date_time_parse_exception",
"reason": "Text '2018-01-17T11:10:42.217Z+00:00' could not be parsed, unparsed text found at index 24"
}
I've had a look at the java.time doc for Instant and there doesn't seem to be a parse method that allows for a dateformatter.
Would you be able to make a suggestion?
I gave that a go but despite whilst it successfully parsed the string it seems to just be culling the zoning entirely.
Using the same DateTimeFormatter constant I used the following:
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.