Quiz: Reading Documents: Scalar Fields

Question: How many movies in the movieDetails collection have exactly 2 award wins and 2 award nominations?
My query

9

But I could’t choose this. What I miss?
Thank you!

Are you trying from compass or shell
What command you have used?
The output 9 is from your command?

{“awards.nominations”:2,“awards.wins”:2}----> from compass

from shell
MongoDB Enterprise Cluster0-shard-0:PRIMARY> db.movieDetails.find({“awards.nominations”:2,“awards.wins”:2}).count()
12

Assuming that you can connect your sandbox from MongoShell, please apply one of these commands.

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

Actually, you don’t have to use find command when you count documents.
or please try from Compass what [Ramachandra_37567] explained in his/her reply. You should find 12 unless you deleted any document from your movieDetails collections.
hope, get it easy.

I haven’t been able to view a single entry for awards in a document. I tried doing this simple filter but it shows 0 document image
I know the lab has two filters but I am yet to find a sample document with awards entry

Please make sure you are connected to correct DB
You are getting zero rows because awards column does not exist
video.movies and video.movieDetails are in different DBs

1 Like

You need to connect to your cluster and in DB: video and collection: movieDetails.

In the screenshot, you are connected to class Cluster(video.movies) which does not have awards field.

Kanika

My approach was a little different although would probably makes sense. Instead of using/querying awards.nominations and awards.wins to count the results, I used awards.text instead because I noticed that the text field summarizes the nominations and wins. It returned a count of 9 for both the Compass and the Shell. See screenshots below:


Now, checking a sample of resulting document why it didn’t match with the {“awards.nominations”:2,“awards.wins”:2} query, I see that some documents doesn’t follow the string value of “2 wins & 2 nominations.”. See below:

My approach was wrong but fun and interesting to know.

I use the same query than you but I obtain 6 in both Compass and Shell

If you used same query as mine definitely your data is the issue
Please check again

Hi @Idrissou_94622,

In this thread, we have established that there was some issue with your import and the dataset was not completely imported.

If you are still facing any issue then please let us know.

~ Shubham