Database
[{"type":"obligation","stuff":{"name":"must-turn-right","shape":"circle"}},{"type":"information","stuff":{"name":"town_name","shape":"square"}},{"type":"obligation","stuff":{"name":"yeld","shape":"triangle"}},{"type":"danger","stuff":{"name":"beware_of_cattle","shape":"triangle"}}]
Query
db.collection.aggregate([{$match:{"stuff.shape":{$exists:true}}},{$group:{"_id":"$stuff.shape"}}])