I'm trying to write a painless script that will return the current date minus 2hours in a format like this - 2017-10-03T11:42:44.279Z
Can I do this in painless?
I'm trying to write a painless script that will return the current date minus 2hours in a format like this - 2017-10-03T11:42:44.279Z
Can I do this in painless?
The current date can not be accessed in a script currently. but you can use the ctx.trigger.scheduled_time
or ctx.trigger.triggered_time
for this - this date is usually around the current date.
Substracting a date would work like this:
Instant.ofEpochMilli(ctx.trigger.scheduled_time.getMillis()).plus(Duration.ofDays(-2))
hope this helps
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
© 2020. All Rights Reserved - Elasticsearch
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.