Database

[{"_id":ObjectId("61efefe39822f4001955f0b5"),"finishedAt":"1644598631","tags":[{"status":1,"thumbnail":"https://storage.googleapis.com/tag-images-dest/5ajH9m2EygoPBgWmCFG59d.webp","subGroup":"sub_tag","name":"Singapore","photo":"https://storage.googleapis.com/tag-images-dest/5ajH9m2EygoPBgWmCFG59d.webp","id":ObjectId("618ea051ccc7a6001bf228a0"),"group":"location"},{"status":1,"thumbnail":"https://storage.googleapis.com/tag-images-dest/9SexZirgstdUhqEFwoEUmT.webp","name":"Marina By the bay","photo":"https://storage.googleapis.com/tag-images-dest/hZESwEyFUfifNiJLhyzKa3.webp","id":ObjectId("61df25818284b0001933cf16"),"group":"location"},{"status":1,"name":"Marina By","id":ObjectId("61df253b8284b0001933cf13"),"group":"location"}],},{"_id":ObjectId("61efefe39822f4001955f0b6"),"tags":[{"status":1,"thumbnail":"https://storage.googleapis.com/tag-images-dest/5ajH9m2EygoPBgWmCFG59d.webp","subGroup":"sub_tag","name":"Canada","photo":"https://storage.googleapis.com/tag-images-dest/5ajH9m2EygoPBgWmCFG59d.webp","id":ObjectId("618ea051ccc7a6001bf228a0"),"group":"location"},],},{"_id":ObjectId("61efefe39822f4001955f0b7"),"tags":[{"status":1,"thumbnail":"https://storage.googleapis.com/tag-images-dest/5ajH9m2EygoPBgWmCFG59d.webp","subGroup":"sub_tag","name":"Canada","photo":"https://storage.googleapis.com/tag-images-dest/5ajH9m2EygoPBgWmCFG59d.webp","id":ObjectId("618ea051ccc7a6001bf228a0"),"group":"location"},{"status":1,"thumbnail":"https://storage.googleapis.com/tag-images-dest/5ajH9m2EygoPBgWmCFG59d.webp","subGroup":"sub_tag","name":"USA","photo":"https://storage.googleapis.com/tag-images-dest/5ajH9m2EygoPBgWmCFG59d.webp","id":ObjectId("618ea051ccc7a6001bf228a0"),"group":"location"},{"status":1,"thumbnail":"https://storage.googleapis.com/tag-images-dest/5ajH9m2EygoPBgWmCFG59d.webp","subGroup":"sub_tag","name":"Singapore","photo":"https://storage.googleapis.com/tag-images-dest/5ajH9m2EygoPBgWmCFG59d.webp","id":ObjectId("618ea051ccc7a6001bf228a0"),"group":"location"},],}]

Query

db.collection.aggregate([{"$match":{"finishedAt":{"$exists":true}}},{"$unwind":"$tags"},{"$match":{"$or":[{"tags.name":"Singapore"},{"tags.name":"ABC"}]}},{"$group":{"_id":null,"count":{"$sum":1}}}])

Result