Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- db.getCollection('RawCollection').aggregate([
- {"$match": {"content.film_id": "1e3b36b3-92a7-4c00-99e9-bc6b19e4e522" }},
- {"$unwind": {"path": "$content.actions", "preserveNullAndEmptyArrays": true}},
- {"$unwind": {"path": "$content.objects", "preserveNullAndEmptyArrays": true}},
- {"$unwind": {"path": "$content.faces", "preserveNullAndEmptyArrays": true}},
- {"$unwind": {"path": "$content.environments", "preserveNullAndEmptyArrays": true}},
- {"$sort": {"actions":1, "objects":1, "faces":1, "environments":1} },
- {"$group": {
- "_id": {"start": "$content.start_time", "end": "$content.end_time", "film_id": "$content.film_id"},
- "actions": {"$push": "$content.actions"},
- "faces_timeline": {"$first": "$content.metadata_faces.timeline"},
- "objects_timeline": {"$first": "$content.metadata_objects.timeline"},
- "actions_timeline": {"$first": "$content.metadata_actions.timeline"},
- "environments_timeline": {"$first": "$content.metadata_environments.timeline"},
- "objects": {"$push": "$content.objects"},
- "faces": {"$push": "$content.faces"},
- "environments":{"$push": "$content.environments"}
- }
- },
- {"$project": {"_id": 0, "film_id": "$_id.film_id", "start": "$_id.start", "end": "$_id.end",
- "feature": {"actions": "$actions", "objects": "$objects", "faces": "$faces", "environments":"$environments"},
- "faces_timeline":"$faces_timeline",
- "objects_timeline":"$objects_timeline",
- "environments_timeline":"$environments_timeline",
- "actions_timeline":"$actions_timeline"
- }},
- {"$sort": {"start": 1}},
- {"$group": {
- "_id": "$film_id",
- "scenes": {"$push": {"feature": "$feature", "start": "$start", "end": "$end",
- "aggregated": {"faces_timeline":"$faces_timeline", "objects_timeline":"$objects_timeline", "environments_timeline":"$environments_timeline",
- "actions_timeline":"$actions_timeline"}}}}}
- ])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement