June 2014
Intermediate to advanced
696 pages
38h 52m
English
Listing 15.9 shows how to implement aggregation against the words collection. It includes three examples.
The first example, in lines 10–20, implements a $match to get words beginning in vowels, then a $group to calculate the largest and smallest sizes. It then sorts the results using $sort, as shown in Figure 15.9.
Figure 15.9 Grouping documents from a MongoDB collection by specific field values.
The second example, in lines 21–27, uses $match to limit the words to four letters. Then $limit is used to process only five documents in the $project operator.
The third example, in lines 28–34, uses $group to get the average size ...
Read now
Unlock full access