i using this script to get sum of average aggregation
Script:
{
"size": 0,
"aggs": {
"by category": {
"terms": {
"field": "spv.keyword"
},
"aggs": {
"by user_id": {
"terms": {
"field": "sales.keyword"
},
"aggs": {
"avg by user": {
"avg": {
"field": "target"
}
}
}
},
"average by user, category": {
"sum_bucket": {
"buckets_path": "by user_id>avg by user"
}
}
}
}
}
}
the value i get is
Value:
"aggregations" : {
"by category" : {
"doc_count_error_upper_bound" : 0,
"sum_other_doc_count" : 0,
"buckets" : [{"key" : "SPV1",
"doc_count" : 13265,
"by user_id" : {
"doc_count_error_upper_bound" : 0,
"sum_other_doc_count" : 0,
"buckets" : [
{
"key" : "SALES1",
"doc_count" : 5184,
"avg by user" : {
"value" : 30.0
}
},
{
"key" : "SALES2",
"doc_count" : 2407,
"avg by user" : {
"value" : 30.0
}
},
{
"key" : "SALES3",
"doc_count" : 2244,
"avg by user" : {
"value" : 30.0
}
},
{
"key" : "SALES4",
"doc_count" : 1977,
"avg by user" : {
"value" : 30.0
}
},
{
"key" : "SALES5",
"doc_count" : 1446,
"avg by user" : {
"value" : 30.0
}
},
{
"key" : "SALES6",
"doc_count" : 7,
"avg by user" : {
"value" : null
}
}
]
},
"average by user, category" : {
"value" : 150.0
}
},
{
"key" : "SPV2",
"doc_count" : 9416,
"by user_id" : {
"doc_count_error_upper_bound" : 0,
"sum_other_doc_count" : 0,
"buckets" : [
{
"key" : "SALES7",
"doc_count" : 3955,
"avg by user" : {
"value" : 30.0
}
},
{
"key" : "SALES8",
"doc_count" : 2655,
"avg by user" : {
"value" : 30.0
}
},
{
"key" : "SALES9",
"doc_count" : 1701,
"avg by user" : {
"value" : 30.0
}
},
{
"key" : "SALES10",
"doc_count" : 1105,
"avg by user" : {
"value" : 30.0
}
}
]
},
"average by user, category" : {
"value" : 120.0
}
}
how can i create a visualization in kibana which has value average by user,category like :
SPV Value
SPV1 150
SPV2 120
Thanks...