Elastic Search 从术语聚合中获取 doc_count 的平均值
Elastic Search getting average of doc_count out of terms aggregation
我在elastic search中有如下terms查询。
GET http://localhost:9200/adapters/request/_search
{
"query": {
"bool" : {
"must" : {
"match" : { "adapterName" : "EnginePushableAdapter" }
},
"filter": {
"range" : {
"request.requestTime" : {
"gte" : 1492080226172,
"lte" : 1492080725964
}
}
}
}
},
"aggs" : {
"call_count" : {
"terms" : {
"field" : "deviceId"
}
}
}
}
有没有办法计算术语聚合返回的 doc_count 的平均值?像这样
"avg_agg" : {
"avg": { "field": "call_count.doc_count" }
}
也就是说,我想对之前的聚合字段取平均值
我认为您可能正在寻找平均桶聚合。
试试
...
"my_count_avg": {
"avg_bucket": {
"buckets_path": "call_count>_count"
}
}
我在elastic search中有如下terms查询。
GET http://localhost:9200/adapters/request/_search
{
"query": {
"bool" : {
"must" : {
"match" : { "adapterName" : "EnginePushableAdapter" }
},
"filter": {
"range" : {
"request.requestTime" : {
"gte" : 1492080226172,
"lte" : 1492080725964
}
}
}
}
},
"aggs" : {
"call_count" : {
"terms" : {
"field" : "deviceId"
}
}
}
}
有没有办法计算术语聚合返回的 doc_count 的平均值?像这样
"avg_agg" : {
"avg": { "field": "call_count.doc_count" }
}
也就是说,我想对之前的聚合字段取平均值
我认为您可能正在寻找平均桶聚合。
试试
...
"my_count_avg": {
"avg_bucket": {
"buckets_path": "call_count>_count"
}
}