elasticsearch 有没有办法从包含最大值的文档中获取字段?(基本上与 scala 中的maxBy类似)
例如(嘲笑):
{
"aggregations": {
"grouped": {
"terms": {
"field": "grouping",
"order": {
"docWithMin": "asc"
}
},
"aggregations": {
"withMax": {
"max": {
"maxByField": "a",
"field": "b"
}
}
}
}
}
}
For which {"grouping":1,"a":2,"b":5},{"grouping":1,"a":1,"b":10}
will return (something like): {"grouped":1,"withMax":5}
,其中最大值来自第一个对象,因为"a"
那里更高。