Database
[{"msg":"A","severity":"hello1","group":"bb"},{"msg":"B","severity":"hello1","group":"bb"},{"msg":"A","severity":"hello2","group":"bb"},{"msg":"C","severity":"hello2","group":"bb"}]
Query
db.collection.aggregate({
$and:[
{
[
{$unwind:"$severity"},
{
$group:{
_id:{$toLower:"$severity"},
count:{$sum:1}
}
}
]
},
{
[
{$unwind:"$msg"},
{
$group:{
_id:{$toLower:"$msg"},
count:{$sum:1},
}
}
]
}]
});