Hi,
I had the following line in a groovy script that I'm attempting to rewrite into painless -
def buckets = ctx.payload.aggregations.metrics.buckets.sort(a,b -> a.largest_surprise.value == b.largest_surprise.value ? 0 : a.largest_surprise.value < b.largest_surprise.value ? -1 : 1);
The compile error I'm getting is "Variable [a] is not defined."
It looks like painless supports the Collections.sort method in java so I tried -
Collections.sort(ctx.payload.aggregations.metrics.buckets, a,b -> a.largest_surprise.value == b.largest_surprise.value ? 0 : a.largest_surprise.value < b.largest_surprise.value ? -1 : 1);
But that also has a compile error - "Unknown call [sort] with [3] arguments on type [Collections]."
Is it possible to sort in painless with a lambda? If so, then what is the syntax? Also, are there any better references for painless than https://www.elastic.co/guide/en/elasticsearch/painless/master/painless-api-reference.html?
Thanks,
Nick