Skip to content

Instantly share code, notes, and snippets.

@iamtrk
Last active December 19, 2015 19:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iamtrk/6006269 to your computer and use it in GitHub Desktop.
Save iamtrk/6006269 to your computer and use it in GitHub Desktop.
M101J from 10Gen Education -> Final exam
Final: Question 2
Please use the Enron dataset you imported for the previous problem. For this question you will use the aggregation framework to figure out pairs of people that tend to communicate a lot(list Top5 pairs).
Query :
db.messages.aggregate([{$unwind:"$headers.To"},{$group:{_id:{from:"$headers.From",to:"$headers.To"},numbe:{$sum:1}}},{$sort:{numbe:-1}},{$limit:5}])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment