To get a list unique, you need either DISTINCT, or GROUP BY. MongoDB supports both paradigms:
To get a list of all the different values tagthat you ran:
db.mycollection.distinct('tag');
or
db.runCommand({ distinct: 'mycollection', key: 'tag' })
and you can get the score simply by looking at the lengthresult:
db.mycollection.distinct('tag').length
Note on the command DISTINCTfrom the documentation:Note: the distinct command results are returned as a single BSON object. If the results could be large (> max document size – 4/16MB ), use map/reduce instead