我学会了如何编写ES查询来计算百分位数,但它似乎适用于一个字段。如果我想要在多个字段上的百分位数,它不起作用。
"aggs": {
"distinct_UUID": {
"terms": {
"field": "cust_uuid"
},
"aggs": {
"perf_percentiles" : {
"percentiles" : {
"field":"A",
"field":"B"
}
}
如果我只有一个字段(字段A或B,但不是两者(,那么上面的代码可以正常工作,但是我想拥有10个或更多字段或更多字段。我该如何解决?
只需添加更多的子附件,每个字段一个:
{
"aggs": {
"distinct_UUID": {
"terms": {
"field": "cust_uuid"
},
"aggs": {
"percentile_a": {
"percentiles": {
"field": "A"
}
},
"percentile_b": {
"percentiles": {
"field": "B"
}
},
"percentile_c": {
"percentiles": {
"field": "C"
}
}
}
}
}
}