0

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.

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

3 Comments

Thank you sooo much @roman . Your solution indeed work, and then after that I went ahead and created a snippet at groovyconsole.appspot.com/script/5084327121518592 , but that could not give me the result I was looking for. I wanted to get the name of the wine, bu tit simply print true . You can click edit in console there to change it
@JVK Well, that should be another question. any returns boolean, you need other methods: [wine,price,taste].transpose().find { w, p, t -> p == 9 }[0]
Yes you are right, that should be another question. I accept your answer and appreciate your help,

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.