Database
db={"books":[{title:"momo",language:"korean",description:"a korean book",tags:[{name:"adventure",description:"genre of fiction in which an adventure, an exciting undertaking involving risk and physical danger, forms the main storyline"},{name:"children",description:"blahblah"},{name:"short",description:"blahblahblah"}]},{title:"momo",language:"korean",description:"a korean book",tags:[{name:"adventure",description:"genre of fiction in which an adventure, an exciting undertaking involving risk and physical danger, forms the main storyline"},{name:"short",description:"blahblah"},{name:"long",description:"blahblahblah"}]},{title:"momo",language:"korean",description:"a korean book",tags:[{name:"children",description:"genre of fiction in which an adventure, an exciting undertaking involving risk and physical danger, forms the main storyline"},{name:"adventure",description:"blahblah"},{name:"long",description:"blahblahblah"}]}]}
Query
db.books.aggregate([{$unwind:"$tags"},{$group:{_id:"$tags.name",count:{$sum:1}}}])