$gte in Aggregation format versus Query format


I am trying to understand something that has eluded me for a while. Why is the

$match: {$gte: ["$imdb.rating", 7 ]}

Not the correct format since it the stated format in the aggregation piple for $gte
$gte (aggregation) — MongoDB Manual

versus MQL query
$match: {$gte: [“imdb.rating”, 7 ]}

Thanks. I just find the mongodb syntax a little bit all over the place with it’s consistency.


$match has been purposely left with the same syntax than find( ), hence $match does not follow aggregation syntax, but MQL syntax (unless you use $expr).

So, when using match, make yourself the idea that you’re writing find, and look up for MQL operators and not aggregation. For example $gte MQL.


Thank you for clarifying.

I am sure it was mentioned somewhere, but I probably wasn’t listening :slight_smile:

Thanks for the extra info on $expr, since I had noticed that in the Basics course when I redid that, but hadn’t bothered to ask the question.

I suppose I just like things to be consistent throughout, without having to learn exceptions.

1 Like