我正在尝试提取与elasticsearch中的函数结果相对应的字段。例如给我具有最大时间戳的记录的字段“elaspsedTime”。理想情况下,我希望将其作为“agss”子句的一部分进行操作
...
"aggs": {
"minStart": {
"min": {
"field": "@timestamp"
}
},
"maxStop": {
"max": {
"field": "@timestamp"
}
},
"elapsedTimeForMax" : {
// field 'elaspedTime' corresponding the 'max' field
}
...
}
这可能吗?
最佳答案
一种方法是使用top_hits
聚合,如下所示:
"aggs": {
"minStart": {
"min": {
"field": "@timestamp"
}
},
"maxStop": {
"max": {
"field": "@timestamp"
}
},
"elapsedTimeForMax" : {
"top_hits": {
"sort": {"@timestamp": "desc"},
"size": 1,
"_source": ["elapsedTime"]
}
}
...
}
关于elasticsearch - 如何在Elasticsearch中获得与函数结果相对应的字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46302305/