How many movies in the movieDetails collection have exactly 2 award wins and 2 award nominations?

So, based on what we learned in the videos, we are induced to connect to the Sandbox Cluster and use the following commands:

use movies
db.movieDetails.count({“awards.wins”:2,“awards.nominations”:2})

the result was 12.

But when i explored the dataset, i realized that awards had a field called “text” which seemed to me to place the awards.wins and awards.nominations like this: “X wins & Y nominations.”

So i tried to run the command:

db.movieDetails.count({“awards.text”:“2 wins & 2 nominations.”})

and the result was 9!

Now i want to continue the courses to see what are the 3 that has 2 award wins and 2 award nominations but does not have the respective text.

@Caio_38938 yeah that won’t work. In one of the videos, there should be a comment about finding partial strings within a text field. Sorry, I didn’t take this course so I can’t tell you which lecture exactly.

1 Like

Hi @Caio_38938,

First of all good question :slight_smile:

The goal is to find all those movies which has exactly two award wins and 2 award nominations. In addition to this we also want to find only those movies which does not have {“awards.text”:“2 wins & 2 nominations.”} as a value.

For this we can do something like this :

db.movieDetails.find({$and:[{"awards.wins":2,"awards.nominations":2},{"awards.text":{$ne:"2 wins & 2 nominations."}}]})

Here, we used $and operator to combine two query expressions. We also used $ne operator to negate the second expression to return only those field whose value is not equal to 2 wins & 2 nominations.

Hope it helps!

If there is anything which is not clear to you then please feel free to get back to us.

Happy Learning :slight_smile:

Thanks,
Shubham Ranjan
Curriculum Support Engineer

1 Like

Following the course lessons, i added the pretty method to visualize better the results.

db.movieDetails.find({$and:[{“awards.wins”:2,“awards.nominations”:2},{“awards.text”:{$ne:“2 wins & 2 nominations.”}}]}).pretty()

Thanks for the reply. I am enjoying a lot the course and i hope i can continue the others. Awesome work you guys did there!