Filter elements of a list using painless syntax

I need to filter a list and transform the payload. Using Elasticsearch 5.6

Example(Groovy)
def list = [1,2,3,4,5]
def result = list.findAll { it > 2 }

The result would be [3,4,5]

This is showing syntax exception in my watcher.
Need a painless syntax to achieve above functionality

try

list.stream().filter(x -> x > 2).collect(Collectors.toList())

Thanks spinscale
Just realized painless corresponds to java 8 syntax.

1 Like

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