Database

[{"item":"Ground Meat","type":"junk","ingredients":{"cheese":"120g","meat":"70g"}},{"item":"Chicken","type":"junk","ingredients":{"cheese":"100g","meat":"60g"}},{"item":"Burger","type":"junk","ingredients":{"cheese":"120g","meat":"50g"}},{"item":"Green Spanich","type":"healty","ingredients":{"Spinach":"12g","Leaves":"1.5g",}},{"item":"Pumpkin Salad","type":"healty","ingredients":{"Spinach":"18g","Leaves":"1.2g",}}]

Query

db.collection.aggregate([{"$project":{"ingredients":"$ingredients"}},{$unwind:"$ingredients"},{$project:{ingredients:{$objectToArray:"$ingredients"}}},{$unwind:"$ingredients"},{$group:{_id:{"k":"$ingredients.k","v":"$ingredients.v"},count:{$sum:1},label:{$last:"$ingredients.k"}}},{"$group":{"_id":"$label",label:{"$last":"anchor"},ingredients:{"$push":{"k":"$_id.v","v":"$count"}}}},{$project:{label:"$label",ingredients:{$arrayToObject:"$ingredients"}}},{"$group":{"_id":"$label",ingredients:{"$push":{"k":"$_id","v":"$ingredients"}}}},{$project:{_id:0,ingredients:{$arrayToObject:"$ingredients"}}}])

Result