JVK JVK - 7 months ago 36
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.


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.