"daily_rank": {
"buckets": [
{
"key_as_string": "2018-08-20T00:00:00.000Z",
"key": 1534723200000,
"doc_count": 2878,
"game": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "a",
"doc_count": 1439,
"count": {
"value": 689593
}
},
{
"key": "b",
"doc_count": 1439,
"count": {
"value": 405340
}
}
]
},
"count": {
"value": 2
}
}
}
I have a query return like above.
How can I get the index number of "key=a" in buckets?
I try to use this
def list = ctx.payload.aggregations.daily_rank.buckets.0.game.buckets;
def index = list.stream().filter(x -> "a".equals(list.get(x).getKey())).findFirst();
But it return java.util.HashMap cannot be cast to java.lang.Number?