Hello
I’m not sure where the rouge " } " is in this $match expression. Not sure what I’m doing wrong, though it looks like even if I got the syntax correct that my operators are incorrect as well. Could someone help me?
Thank you
Nicholas
Hello
I’m not sure where the rouge " } " is in this $match expression. Not sure what I’m doing wrong, though it looks like even if I got the syntax correct that my operators are incorrect as well. Could someone help me?
Thank you
Nicholas
Seems like my issue is with multiple filters. I can create a single filter with match like this one:
Hey @Nicholas_90117, it’s shaped like this:
[
{
$match: {
field_1: criteria_1,
field_2: criteria_2,
field_3: criteria_3
}
}
]
Can you spot the problem now?
Thank you @007_jb for the response. I was able to create a $match aggregate with 4 and 5 different filters.
Now my questions is, how am I incorrectly filtering? I got 919, not the 23 that I’m expecting.
Couple of tips:
genres
filter can be mergedrated
condition, $in
is equivalent to $or
languages
condition is not quite right. There are some operators that you need to research that weren’t discussed in any of the prior lectures. Here’s the reference.If you do get it right, or you’re close, please don’t post it on here.
Wow @007_jb I fixed 1 and 2 before you posted… and thank you for the link, I fixed 3.
But I still have come up with 24 instead of 23. So there’s something off i guess.
Which operator did you use for 3?
“languages”: {$all : [“English”,“Japanese”]}
Double check all the conditions, there’s something off there. Also run the validate to see if one of the answers matches.
Swap the backslash (\) for a forward slash (/).
I just got it, right be fore you replied haha… thank you, now I’m getting You aren’t returning the correct number of documents. So still working on the filters.
Clever guy
Let us know how it goes.
Ok, so there’s a document with a genre of “Crime” that’s getting through. I don’t know why though.
“genres”: {$nin: [“Crime”]} <-- this is in my $match
Horror is missing
I thought I already eliminated that possibility by separating them:
“genres”: {$nin: [“Crime”]},
“genres”: {$nin: [“Horror”]},
I’ve edited my post. It should have pointed to suggestion 1 instead of 2. The point I’m making is, you need to merge both conditions. Just like you’ve done with “$in”.
Sorry, I communicated poorly, this is what it was:
$or :[{“genres”: {$nin: “Crime”}}, {“genres”: {$nin: “Horror”}}]
same result, 24 instead of 23 docs
I understood what you wrote that’s why I’m again hinting that you need to merge both conditions.
The $or
is the culprit and you only need to use one genres
field, not two.
k, got it. I would have given up so quickly without you @007_jb
On to the next lecture! Don’t get comfortable