JVK JVK - 1 year ago 63
Groovy Question

Syntax error in groovy script - what is wrong?

I am trying to execute the following groovy script snippet in my elasticsearch dsl scripting:

[doc['availabilities.start'], doc['availabilities.end']].transpose().any { (start, end) -> end.date.getMillis() >= 11 } return 2;


and this throws the following error
enter image description here

I am pretty new in Groovy and unable to figure out what is the wrong syntax here. Any help will be appreciated.

Answer Source

Groovy doesn't use parentheses around closure parameters, so that should be

.any { start, end -> end.date.getMillis() >= 11 }

And return 2; at the end discards the result of the previous expression, I'm not sure if that was your intention.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download