Advertisement
Guest User

Untitled

a guest
May 21st, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.28 KB | None | 0 0
  1. db.getCollection('RawCollection').aggregate([
  2.  
  3. {"$match": {"content.film_id": "1e3b36b3-92a7-4c00-99e9-bc6b19e4e522" }},
  4. {"$unwind": {"path": "$content.actions", "preserveNullAndEmptyArrays": true}},
  5. {"$unwind": {"path": "$content.objects", "preserveNullAndEmptyArrays": true}},
  6. {"$unwind": {"path": "$content.faces", "preserveNullAndEmptyArrays": true}},
  7. {"$unwind": {"path": "$content.environments", "preserveNullAndEmptyArrays": true}},
  8.  
  9. {"$sort": {"actions":1, "objects":1, "faces":1, "environments":1} },
  10. {"$group": {
  11. "_id": {"start": "$content.start_time", "end": "$content.end_time", "film_id": "$content.film_id"},
  12. "actions": {"$push": "$content.actions"},
  13. "faces_timeline": {"$push": "$content.metadata_faces.timeline"},
  14. "objects_timeline": {"$push": "$content.metadata_objects.timeline"},
  15. "actions_timeline": {"$push": "$content.metadata_actions.timeline"},
  16. "environments_timeline": {"$push": "$content.metadata_environments.timeline"},
  17. "objects": {"$push": "$content.objects"},
  18. "faces": {"$push": "$content.faces"},
  19. "environments":{"$push": "$content.environments"}
  20.  
  21. }
  22. },
  23. {"$project": {"_id": 0, "film_id": "$_id.film_id", "start": "$_id.start", "end": "$_id.end",
  24. "feature": {"actions": "$actions", "objects": "$objects", "faces": "$faces", "environments":"$environments"},
  25. "faces_timeline":"$faces_timeline",
  26. "objects_timeline":"$objects_timeline",
  27. "environments_timeline":"$environments_timeline",
  28. "actions_timeline":"$actions_timeline"
  29. }},
  30. {"$sort": {"start": 1}},
  31. {"$group": {
  32. "_id": "$film_id",
  33. "scenes": {"$push": {"feature": "$feature", "start": "$start", "end": "$end",
  34. "aggregated": {"faces_timeline":"$faces_timeline", "objects_timeline":"$objects_timeline", "environments_timeline":"$environments_timeline",
  35. "actions_timeline":"$actions_timeline"}}}}}
  36.  
  37. ])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement