Chapter1 Lab $match having problems

I’m not getting the result of 23 from the aggregate pipeline. How can I get help to understand what I’m doing wrong without giving someone else the answer? I’ve spent over 8 hours trying to figure this out on my own using different options and ordering of the operators. It would be nice if someone could at least say, here is the code that is wrong.

I don’t know what to do. I’m not learning like this…

How many are you getting?

I’m getting a very short list of 5 or 4 or a large list of 259. The problem I may be having is in the wording of the languages requirement. Do the records have both languages in the list. As in the following.

“languages” : [

If I use an in operator so that English and Japanese are in the list, then I only get the 4 or 5 records. I thought that is what the requirement is when it says. languages contains “English” and “Japanese”. But if I do an in list with Japanese or English in the list I get 259.I must not have the correct code to find English and Japanese in the language list regardless of position.

Yes, “and” is the keyword here:

Have a look at this:

I did the following order based on the requirements,

imdb rating greater than equal to 7, rated equal to PG rated equal to G, languages of English and Japanese using all, genres of not in for Crime and Horror and I get 9 rows… Ugh.

The order doesn’t actually matter but you’re getting there. I believe your problem now is with rated. The rated field must only appear once, not twice. Have a think.

Thinking… thanks. but I still say UGHHHHH! That clue helps.

Basically you need to use the $in operator on the rated field.

How’s that for a hint? :wink:

That’s what I was going to try…thanks.

I thought your hint would work. Now I get 877 records…

It all depends on implementation… post your full code. And I’ll let you know when to delete the post.

It’s got to be something stupid. I’m used to sql… still learning…

Here it is.

Alright. You can delete your last post.

You said that you used $all but from your last post, you reverted back to your old code.

I told you it was stupid! LOL. version control is a killer.

Thank you. I now have 23 records and the correct code.

Good man! :slight_smile: :+1:

Hi @Phil_Stout_57454 @007_jb,

This thread is a good example of debugging with patience.

Great efforts @Phil_Stout_57454 in figuring out the issue.
I would also recommend you to go through the documentation to understand more examples:

Commendable efforts by @007_jb for helping the user.