In the lab exercise for “Comparison Operators”, the instruction is:
“Using the $in operator, filter the video.movieDetails collection to determine how many movies list “Ethan Coen” or “Joel Coen” among their writers. Your filter should match all movies that list one of the Coen brothers as writers regardless of how many other writers are also listed. Select the number of movies matching this filter from the choices below.”
I got two different results:
MongoDB Enterprise Sandbox-shard-0:PRIMARY> db.movieDetails.find(
… {“writers”: {$in: [“Ethan Coen”, “Joel Cohen”]}},
… {"_id": 0, “title”: 1, “rated”:1}
… )
{ “title” : “The Big Lebowski”, “rated” : “R” }
{ “title” : “Toy Story”, “rated” : “G” }
{ “title” : “No Country for Old Men”, “rated” : “R” }
{ “title” : “Paris, je t’aime”, “rated” : “R” }
MongoDB Enterprise Sandbox-shard-0:PRIMARY> db.movieDetails.find(
… {“writers”: {$in: [“Joel Coen”, “Ethan Cohen”]}},
… {"_id": 0, “title”: 1, “rated”:1}
… )
{ “title” : “The Big Lebowski”, “rated” : “R” }
{ “title” : “No Country for Old Men”, “rated” : “R” }
{ “title” : “Paris, je t’aime”, “rated” : “R” }
As you can see, reversing the order “Joel Coen” and “Ethan Coen” gives me two different results; “Toy Story” is the only movie which lists only one brother (Joel Coen). Given the request in the topic – “how many movies list “Ethan Coen” or “Joel Coen” among their writers” – then the correct answer to this question should be 4. However, that option is not listed in the multiple-choice lab, and the correct answer is supposed to be 3.
This lab question is formulated as an OR request (how many movies list “Ethan Coen” or “Joel Coen” ), but the answer considered to be correct is appropriate only for an AND request.
Can you explain this discrepancy? Thank you.