Hi,
i am trying to group all the visited product by each user.
when i execute this aggregation:
{
"size":0,
"aggs" : {
"distinctroles": {
"terms": {
"field": "roles"
},
"aggs": {
"consultedproducts": {
"terms": {
"field": "productcode"
}
}
}
}
}
}
it returns all the roles and all the products:
"buckets": [
{
"key": "role_customergroup",
"doc_count": 3124,
"consultedproducts": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "847942",
"doc_count": 639
},
{
"key": "1312640",
"doc_count": 438
},
{
"key": "458542",
"doc_count": 438
},
{
"key": "1992695",
"doc_count": 224
},
{
"key": "872912",
"doc_count": 219
},
{
"key": "2938458",
"doc_count": 217
},
{
"key": "4812254",
"doc_count": 214
},
{
"key": "824267",
"doc_count": 214
},
{
"key": "1776947",
"doc_count": 205
},
{
"key": "805693",
"doc_count": 110
}
]
}
},
{
"key": "role_pronto",
"doc_count": 1945,
"consultedproducts": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "847942",
"doc_count": 639
},
{
"key": "1312640",
"doc_count": 438
},
{
"key": "458542",
"doc_count": 438
},
{
"key": "1992695",
"doc_count": 224
}
]
}
}
}
am I doing something wrong?