Comparison (<) not supported on datetime fields anymore since upgrade to 6.1

(Simon Stemplinger) #1

I have a scripted field that looks something like this:

(doc['actual_time'].value < doc['expected_time'].value) ? 1 : 0

Since the upgrade to 6.1 I'm getting the following error:

caused_by":{"type":"class_cast_exception","reason":"Cannot apply [<] operation to types [org.joda.time.MutableDateTime] and [org.joda.time.MutableDateTime]."

The error message is rather confusing, as accoriding to The MutableDateTime class implements Comparable and should therefore support < comparisons.

What's the correct way to compare timestamp fields in 6.1?

Thanks in advance,

Compare Dates in Script Query
(David Pilato) #2

Can you call then getMillis()?

(Simon Stemplinger) #3

Yep, that does it as a workaround. Thanks! :grinning:

(system) #4

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.