How can I do date-calculation/conversion in an MVEL script in ES 1.0.0?


(h.b.wassenaar) #1

Hello,

I'm considering upgrading from 0.90.3 to 1.0.0, but I've hit a snag with
one of the MVEL scripts I use to update documents through the update api.
My update-script uses Joda to parse/format/manipulate dates, but it appears
that Joda is no longer available to MVEL scripts in version 1.0.0. (I think
it changed in commit c7f6c52 from november 24th, so it's been like that for
a while)

Here are some code-snippets of how it currently works

parser = Joda.forPattern('dateOptionalTime').parser();
lastdate = parser.parseMillis(update.date);
prevdate = parser.parseMillis(ctx._source.published);
timediff = lastdate-prevdate;
...
nextdate=parser.parseMutableDateTime(update.date);
nextdate.addHours(calculated_hours);
ctx._source.nextupdate =
nextdate.toString('YYYY-MM-dd'T'HH:mm:ss'Z'');

Is there some way to do similar date/time calculations in ES 1.0.0?

I've considered I could use a native script to do these updates; however,
when I wrote the update-script I tested this, and to my surprise using a
native script proved to be significantly slower than using the MVEL script
for this use-case.

Any help would be much appreciated,
-- Harmen

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/a263df38-557e-4221-9b71-19ba78737edf%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(system) #2