Example of my documents:
[
{
username: 'userA',
action: 'click',
page: 'home'
},
{
username: 'userA',
action: 'click',
page: 'home'
},
{
username: 'userA',
action: 'scroll',
page: 'home'
},
{
username: 'userA',
action: 'click',
page: 'productA'
},
{
username: 'userB',
action: 'scroll',
page: 'productA'
},
...
]
Example of the nested aggregation I need:
{
userA: {
home: {
click: 2,
scroll: 1
},
productA: {
click: 1
},
},
userB: {
productA: {
scroll: 1
}
}
...
}
I have this code working so far but I don't understand how to nest:
POST /index/_search?size=0
{
"aggs" : {
"usernames" : {
"terms": {
"field" : "username.keyword",
"size": 10000
}
}
}
}
This gives me all usernames which is a good start but how to I get the second nested aggregation per username?