1

I need to know total count of tags in mongodb. For example in below documents there are total 5 tags.

My documents are like-

{ 
    "_id" : ObjectId("59c2102e2526c34768e405f5"), 
    "Name" : "Ashish", 
    "tags" : [
        "java", 
        "python", 
        "c"
    ]
},
{ 
    "_id" : ObjectId("62c2102e2526c34768e405l8"), 
    "Name" : "Binay", 
    "tags" : [
        "Dotnet", 
        "perl"
    ]
}
Ashish Kumar
  • 261
  • 3
  • 10
  • 1
    It is a very basic question but i am completely new in MongoDB. Thanks – Ashish Kumar Sep 21 '17 at 06:35
  • 2
    `db.collection.aggregate([{ "$group": { "_id": null, "count": { "$sum": { "$size": "$tags" } } }}])`. Very basic questions already have answers. Look for them before posting please. – Neil Lunn Sep 21 '17 at 06:37

0 Answers0