$not in $match query returns an error

Hi, it is me again, I think I was able to construct the $match query but I am getting an error on the logical $not operator. It works with $and.

… rest of $match ----------- , $or: [ { “genres”: “Crime”} , {“genres”: “Horror”}] , …rest of $match

if I replace the $or by $and I don’t get any error.

$or and $and take an array as argument which $not take a single expression.

So ‘$or : [ … ]’ and ‘$and : [ … ]’ but ‘$not : { … }’

Ok, I realize that it was $not what was being requested.

------ , “genres”: { $not: {“Crime”}} , “genres”: { $not: {“Horror”}}, -----------

Is this the correct way to use $not

@ Ernesto_47832

The documentation on $not (aggregation) is here. Look it up.

In general, it will be best for you to use the documentation as a resource not the Forum; you always have the docs; you don’t always have someone helpful and knowledgeable to give you answers. Good luck.

I completly understand but I am not used to get things the easy way. it is just that time is running out for me and this course. Also, it is encouraged from the videos to use the forum to ask questions. I am not looking for full exercise answers but a little guidance. Thank you for the link. i didn’t know there was a different $not for aggregations.

@ Ernesto_47832

Yep. That’s why I put the link in the reply – it isn’t intrinsically obvious that many of the query operators have a slightly different syntax in an aggregation pipeline.