Du viser ikke, hvordan dokumenterne i din samling ser ud, men du kan bruge aggregate
indsamlingsmetode for at gøre dette:
// Group by the first letter of the 'words' field of each doc in the 'test'
// collection while generating a count of the docs in each group.
db.test.aggregate({$group: {_id: {$substr: ['$words', 0, 1]}, count: {$sum: 1}}})