我有一组具有唯一数字运行ID的文档,我想找到运行ID最高的文档.
我可以做两个查询.
首先,我可以找到最高运行ID:
{
"size": 0,
"aggregations": {
"latest_run_id": {
"aggregations": {
"latest_run_id": {
"max": {"field": "run_id"}
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
其次,我可以找到运行id的文件:
{
"filter": {
{"term": {"run_id": latest_run_id}}
}
}
Run Code Online (Sandbox Code Playgroud)
有没有办法用一个查询来做到这一点?