Javi

Mongodb: enron aggregation

Oct 9th, 2015
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. db.messages.aggregate([
  2. { $unwind: "$headers.To"
  3. },
  4. {
  5. $project: {
  6. "_id": 1,
  7. "headers.From": 1,
  8. "headers.To": 1
  9. }
  10. },
  11. {
  12. $group: {
  13. _id: { id: "$_id", from: "$headers.From", to: "$headers.To" },
  14. count: { $sum: 1 }
  15. }
  16. },
  17. {
  18. $group: {
  19. _id: { from: "$_id.from", to: "$_id.to" },
  20. count: { $sum: 1 }
  21. }
  22. },
  23. {
  24. $sort: {
  25. count: -1
  26. }
  27. },
  28. {
  29. $limit: 5
  30. }
  31. ], {
  32. allowDiskUse:true,
  33. cursor:{}
  34. })
Advertisement
Add Comment
Please, Sign In to add comment