You need to have hollywood database with actors collection (see mongodb.txt).
1.
Add attribute gender: male/female to each document in the actors collection (if it doesn't exist) Add at least 5 more actors (each with at least 3 movies) to the actors collection from Lab3.
2.
If you run db.movies.find() you should see something like:
{ "_id" : { "movie" : "Chicago" }, "value" : { "actors" : [ "Richard Gere III" ] } }
{ "_id" : { "movie" : "Osage County" }, "value" : { "actors" : [ "Meryl Streep", "Julia Roberts" ] } }
{ "_id" : { "movie" : "Pretty Woman" }, "value" : { "actors" : [ "Julia Roberts", "Richard Gere III" ] } }
{ "_id" : { "movie" : "Runaway Bride" }, "value" : { "actors" : [ "Julia Roberts", "Richard Gere III" ] } }
{ "_id" : { "movie" : "The Devil Wears Prada" }, "value" : { "actors" : [ "Meryl Streep" ] } }
{ "_id" : { "movie" : "The Iron Lady" }, "value" : { "actors" : [ "Meryl Streep" ] } }
Using map/reduce and post-processing please show how to create movies collection that has documents with only female actors in the following form:
{ "_id" : { "movie" : "Osage County" }, "actors" : [ "Meryl Streep", "Julia Roberts" ] }
{ "_id" : { "movie" : "Pretty Woman" }, "actors" : [ "Julia Roberts"] }
Note: You need to find the most optimal way to do this.
3.
Delete movies collection and re-create it using the aggregation pipeline approach. The documents in the movies collection must be in the modified form shown in Q2. Just like in Q2, only female actors must be listed.
Add the following to the aggregation pipeline:
- Actors must be listed sorted in ascending order
What to submit:
1. db.actors.insert(....) statements for at least 5 actors.
2. Your map/reduce functions.
3. You must provide the MongoDB aggregation statements that you used to produce the movies collection. Also, you need to submit collections from hollywood database in JSON format (files actors.json and movies.json):
mongoexport --db hollywood --collection=actors --type=json --out actors.json
mongoexport --db hollywood --collection=movies --type=json --out movies.json
Attachment:- mongodb.txt