服务器运行环境信息: Linux
软件版本: 7.10
问题发生的上下文信息;
使用rang返回的是个数,怎么统计百分比
软件版本: 7.10
问题发生的上下文信息;
使用rang返回的是个数,怎么统计百分比
GET /index-001/_search
{
"aggs": { //聚合操作
"diff_time_ranges": { //自定义组名名称
"range": { //分组
"field": "diffTime",
"ranges": [
{
"to": 60
}, // < 1min
{
"from": 60,
"to": 300
}, // 1min < x < 5min
{
"from": 300,
"to": 600
}, // 5min < x < 10min
{
"from": 3600
} // > 1h
]
}
}
},
"size": 0 //可选, 不带原始数据, 否则:"hits":{}这个原始数据也会暴露出来
}
返回结果{
"took": 129,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 3982,
"relation": "eq"
},
"max_score": null,
"hits":
},
"aggregations": {
"diff_time_ranges": {
"buckets": [
{
"key": "*-60.0",
"to": 60.0,
"doc_count": 3947
},
{
"key": "60.0-300.0",
"from": 60.0,
"to": 300.0,
"doc_count": 7
},
{
"key": "300.0-600.0",
"from": 300.0,
"to": 600.0,
"doc_count": 1
},
{
"key": "3600.0-*",
"from": 3600.0,
"doc_count": 3
}
]
}
}
}
比如我要求出每个range记录占总数的百分比, 比如第一条 (3947 / hits.total.value) * 100,第二条 (7 / hits.total.value) * 100, 估计要写pipeline,请问怎么写呢
1 个回复
Charele - Cisco4321
赞同来自: