Retrieve Movies with viewer rating higher than 4 on tomatoes
Retrieve all movies from the 'movies' collection that have complete information and have a viewer rating higher than 4 on Tomatoes.
Structure of 'movies' collection:
{ _id: ObjectId("573a1390f29313caabcd42e8"), plot: 'A group of bandits stage a brazen train hold-up, only to find a determined posse hot on their heels.', genres: [ 'Short', 'Western' ], runtime: 11, cast: [ 'A.C. Abadie', "Gilbert M. 'Broncho Billy' Anderson", 'George Barnes', 'Justus D. Barnes' ], poster: 'https://m.media-amazon.com/images/M/MV5BMTU3NjE5NzYtYTYyNS00MDVmLWIwYjgtMmYwYWIxZDYyNzU2XkEyXkFqcGdeQXVyNzQzNzQxNzI@._V1_SY1000_SX677_AL_.jpg', title: 'The Great Train Robbery', fullplot: "Among the earliest existing films in American cinema - notable as the first film that presented a narrative story to tell - it depicts a group of cowboy outlaws who hold up a train and rob the passengers. They are then pursued by a Sheriff's posse. Several scenes have color included - all hand tinted.", languages: [ 'English' ], released: ISODate("1903-12-01T00:00:00.000Z"), directors: [ 'Edwin S. Porter' ], rated: 'TV-G', awards: { wins: 1, nominations: 0, text: '1 win.' }, lastupdated: '2015-08-13 00:27:59.177000000', year: 1903, imdb: { rating: 7.4, votes: 9847, id: 439 }, countries: [ 'USA' ], type: 'movie', tomatoes: { viewer: { rating: 3.7, numReviews: 2559, meter: 75 }, fresh: 6, critic: { rating: 7.6, numReviews: 6, meter: 100 }, rotten: 0, lastUpdated: ISODate("2015-08-08T19:16:10.000Z") } .....
Query:
db.movies.find({
"tomatoes.viewer.rating": { $gt: 4 }
})
Output:
{ _id: ObjectId("573a1391f29313caabcd8945"), plot: 'A married farmer falls under the spell of a slatternly woman from the city, who tries to convince him to drown his wife.', genres: [ 'Drama', 'Romance' ], runtime: 94, rated: 'NOT RATED', cast: [ "George O'Brien", 'Janet Gaynor', 'Margaret Livingston', 'BodilRosing' ], num_mflix_comments: 1, poster: 'https://m.media-amazon.com/images/M/MV5BNDVkYmYwM2ItNzRiMy00NWQ4LTlhMjMtNDI1ZDYyOGVmMzJjXkEyXkFqcGdeQXVyNTgzMzU5MDI@._V1_SY1000_SX677_AL_.jpg', title: 'Sunrise', fullplot: 'In this fable-morality subtitled "A Song of Two Humans", the "evil" temptress is a city woman who bewitches farmer Anses and tries to convince him to murder his neglected wife, Indre.', countries: [ 'USA' ], released: ISODate("1927-11-04T00:00:00.000Z"), directors: [ 'F.W. Murnau' ], writers: [ 'Carl Mayer (scenario)', 'Hermann Sudermann (from an original theme by)', 'Katherine Hilliker (titles)', 'H.H. Caldwell (titles)' ], awards: { wins: 5, nominations: 1, text: 'Won 3 Oscars. Another 2 wins & 1 nomination.' }, lastupdated: '2015-09-12 00:26:13.493000000', year: 1927, imdb: { rating: 8.4, votes: 24480, id: 18455 }, type: 'movie', tomatoes: { viewer: { rating: 4.4, numReviews: 9134, meter: 92 }, dvd: ISODate("2008-12-09T00:00:00.000Z"), critic: { rating: 8.9, numReviews: 48, meter: 98 }, lastUpdated: ISODate("2015-09-10T19:15:02.000Z"), consensus: 'Boasting masterful cinematography to match its well-acted, wonderfully romantic storyline, Sunrise is perhaps the final -- and arguably definitive -- statement of the silent era.', rotten: 1, production: 'Fox Films', fresh: 47 } },
Explanation:
The said query in MongoDBretrieves movies from the 'movies' collection that have a viewer rating greater than 4 on Tomatoes.
In the find() method the $gt operator filters documents where the viewer rating of a movies greater than 4.
Improve this sample solution and post your code through Disqus.
Previous: Retrieve movies with complete information and IMDb rating higher than 7.
Next: Retrieve movies with awards from 'movies' collection.
What is the difficulty level of this exercise?
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics