Exercises
Exercise 1
Use restaurants.json
Using aggregation framework, print documents below.
1. Find Korean cuisine
2. Group by borough and count the cuisines.
Exercise 2
Using aggregation framework, print documents below.
1. Find Korean cuisine
2. Unwind grades
3. Group by borough and grade in grades, and count the document
4. Sort by count and print five documents
Exercise 3
Find international airports in California using aggregate framework
states collection
Get the California location (Polygon)
airports collection
Find “intl” in name field (text)
Find airports in the California
Project name, type and code (w/o _id)
Sort by name (ascending order) and code (descending order)
Exercise 4
Find Korean restaurants that are located at less 2km from international airports (use the type field).
Warn: should create 2dsphere index to address for restaurants collection.
Exercise 5
Print the average, minimum, and maximum of passengers(ride_pasgr_numfield) of each subway line.
Hint: group by the ‘line_num’ field and use $max, $min, and $avg.
Result
Exercise 6
Print the total number of passengers (ride_pasgr_numfield) during 2017-12-21 ~ 2017-12-28.
‘use_dt’ is a stringtype.
Hint: use $match,$gt$lt, $sum, $sort
Result
Last updated