Question 6: "Either of"

Hi all,
sorry for my bad english but the sentence below is a bit confusing to me:

  • The cast includes either of the following actors: “Jack Nicholson”, “John Huston”.

“Either of” in this case means:

  1. Both of them
  2. One or the other (having only one of the two is ok)
  3. None of them

Could you please tell me which one? Google tells me 1 but I’m not that sure, therefore I prefer to ask you :slight_smile:

Thanks,
Luca.

1 Like

any of the 2, viewerRating> 7, mpaaRating = R

2 Likes

Correct.

  • “Either OF” is “any of these”.
  • “Either OR” is “one or the other, but not both”.
3 Likes

Thanks a lot!!!

Luca

I am having an issue with this question, it is a bit confusion…
Are we trying to determine if there are movies that EITHER OR
falls into one of the criteria Ie.
Actor, AND either one of the other viewerRating > 7 and MpaaRating=R –
I have to agree with Luca, the wording is a bit CONFUSING and MISLEADING

See my earlier reply: it’s one or the other. That’s what “either of” means.

Basically you looking for documents where:-

The cast includes Jack Nicholson OR John Huston (can be both, however since OR only requires one component to be a match), how you implement that, is up to you, since there are a number of ways.

So we should use Or operator, greater than and equal to operators to get the correct answer?

I think that for that task we should use $in operator.

3 Likes

Yes a $in would work in this case for the $or.

thanks all

it worked and got the correct output
using

$in,$gt,$eq operators

1 Like

I have written the query but unsure of the database to run this against. Executed against the cluster.mflix and not getting any of the listed answers. The cluster.video does not contain movieDetails collection. Can you point me to the right database please

As mentioned in the Question: “Please connect to the M001 class Atlas cluster from the mongo shell or Compass and view the video.movies collection.”

Please connect to our Atlas cluster “cluster0-shard-00-00-jxeqq.mongodb.net:27017”:

Database: video
Collection: movies

Kanika

1 Like

There is an answer from docs:

$or versus $in

When using $or with <expressions> that are equality checks for the value of the same field, use the $in operator instead of the $or operator.

https://docs.mongodb.com/manual/reference/operator/query/or/#or-versus-in

I used $all instead of $in operator .

@stefano_53715
That will return you all films that have BOTH Jack Nicholson and John Huston. That is not what the question is asking. It’s asking films that have EITHER OR (meaning it can have one actor or both to qualify).

Thanks you are right

Yup. I messed up the verbiage as well. I know now that my answer is incorrect. Ugh.

You still have some time to answer the question. Till then, you can go back and try again as many times as you wish.

this was the most complex I used all, eq and gt and besides that I used it with and I found the answer