Lab-$match Homework

I am getting syntax error for below query:
< deleted >

Error: [js] SyntaxError: invalid property id @(shell):2:1
Please help me out as soon as possible?

I had the exact same issue with the identical query. It seems that $match needs it’s expression to use $expr type expressions… which doesn’t exactly match the lecture… Look at $match in the documentation for what I mean. I had to treat the query expression for $match like a $find query.

BUT - your search conditions DO match what I got to work… so you’re very close

Thanks for your quick reply…But eventhough i used $expr in syntax… i am getting same error.
< deleted >

I figured it out…finally… By removing unnecessary braces and forgot to add quotations around match aggregrate operator.

Please do not post potential answers. My suggestion is to simplify your pipeline by removing part of it until you find the part that cause the error. Personally when I work a complex query, I put each part in a variable. This way it is simple to take parts out and in.

For example:

var genresPart = ...
var ratedPart = ...
var pipeline = ... ,
    genresPart ,


Please follow Forum guidelines and do not post code – correct or incorrect – here. I have edited your posts to remove that (closing the stable door after the horse is out to some extent :wink: ). Also @steevej-1495 recommendations are very good and worth following.

sorry for keeping that post…i was little confused about error which i got and so i posted to identify my mistake.i’ll be careful from posting code directly.Thank you for letting me know


No problem – it’s a natural mistake and lots of students make it. But it’s better for the community if folks work out their problems with some help, not if they simply copy someone else’s code. Thanks for being understanding.