Feedback on Chapter 2 Lab 1

Re: “For movies released in the USA […]”

I spent a long time trying to figure out what was wrong with my pipeline, until I considered that the issue might be this phrasing, and it was. If it’s meant to be exclusively the USA, please say that; otherwise it can be interpreted to mean that countries include (but are not necessarily limited to) the USA.

1 Like

Hi,

Indeed that is the correct interpretation, movies that include USA in the countries field, e. g. a movie where “countries” : [ “France”, “USA” ] should be returned.

José Carlos

Maybe I’m misunderstanding something, then. I kept getting a wrong answer when my $match section contained:
countries: “USA”,
to pull back USA as one of (but not necessarily the sole) element. When I tried changing it to
countries: [“USA”],
I got the correct solution.

what happens if you use this syntax? :
“countries”: {$in: [“USA”, “$countries”]}

Hi @cfhulsey

Could you send me your pipeline please? Try sending me a private message.

José Carlos

Hello,

I’m facing the same issue. I get the correct answer if I match documents where countries: [“USA”].
Can you confirm that this is correct ?

Thanks,

Bart

Regarding the Countries stage of the query, i am getting different output with different usage.

The following usage gives different results:

countries: [“USA”]

countries: {$in: [“USA”]}

I get the correct result only when i remove country from the $match stage. I am confused if i am doing the right thing here.

I understood, what went wrong with my query.

Glad you managed to solve it!