Lab using cursor-like Stages

I start by using $match on “countries” and “tomatoes.viewer.rating”. This cuts the count by more than half. Next I $addFields for num_favs. Then I try $match trying to pull from cast all of the num_favs. No syntax errors, but no data either. I’m having trouble trying to figure out how to use num_favs.

Remove the $match added after $addFields to give you a taste of the document shape. It might help you figuring what’s wrong with the $match.

Any hint on the $addFields? I am stuck as well

What did you try? What issues did you get?

Post screenshots of the problems you faced.

After the $addFields I have over 15k docs and an array of the num_favs.
image

Next, I’m trying to use $in in the $match next stage and it picks no documents (no error either)

I think num_favs should be a count, not an array. May be you are missing some operation. In chapter 1 they cover, on one of the lab, the operator that you are missing.

Hi @Steve_33394,

Please check your discourse inbox and feel free to share your pipeline there to debug the same.

Thanks,
Sonali

Hi Sonali, you sent me a screen shot previously showing an envelope icon indicating that is was the discourse inbox. I don’t seem to have that:image

Hi @Steve_33394,

If you click on your icon, you should see the following options:

Click on “envelope” icon to vie the discourse inbox messages.

Please let me know if you are still facing any issue.

Thanks,
Sonali

Yea…I don’t have that choice:image

Any help on my portal not offering an email selection?

Hi
num_favs should not be equal to [
‘Sandra Bullock’,
‘Tom Hanks’,
‘Julia Roberts’,
‘Kevin Spacey’,
‘George Clooney’,
]
It should be equal to how many of these actors appear in the cast field of a document. e.g. if cast: [“Tom Hanks”, “Kate Winslet”] then num_favs should be equal to 1.

Hint: First you need to find matching names between cast field and [ ‘Sandra Bullock’, ‘Tom Hanks’, ‘Julia Roberts’, ‘Kevin Spacey’, ‘George Clooney’,]. Chapter one labs have covered the required opertor. then you can calculate the size of matched array

I’m trying this $project stage and I get a warning that it is not properly formatted:
{
num_favs:
$setIntersection: ["$cast", “$favorites”]
}

{
num_favs: {
$setIntersection: ["$cast", “$favorites”]

}
}

You forgot curly braces

This comes back as null. I’m trying to add $size before $setIntersection.

I can not help without looking at how you are constructing your pipeline. Posting code here is not good. I do not know if there is feature where you can share your code privately to me on the discussion forum

Hi @Steve_33394,

The discourse users cannot initiate the personal messages on the discussion forum as only admins have rights to do so.

I have sent you another direct message, you can click on its notification and reply to the same thread.

However, if you still face any issues, feel free to email us on university@mongodb.com and I will help you out there.

Please feel free to reach out if you have any additional questions.

Thanks,
Sonali

The problem I’m facing is that the result of my $setIntersection does not appear to be an array, in the mongo shell, is there any procedure that could convert this operation into an array?

Hi @Mots_Mokhanoi,

Please check your discourse inbox message and reply there with your aggregation pipeline.
Let me know if you have any questions.

Thanks,
Sonali