Need sanity check on $elemMatch operator

Greetings - the following query returns something, even though it’s not what we’re looking for:

MongoDB Enterprise Cluster0-shard-0:PRIMARY> db.surveys.find({“results.product”: “abc”, “results.score”: 7}).count()
172
MongoDB Enterprise Cluster0-shard-0:PRIMARY>

But when I try to refine the search using $elemMatch, I get an error. I must be making a very simple but dumb mistake. What am I doing wrong here?

query result:

MongoDB Enterprise Cluster0-shard-0:PRIMARY> db.surveys.find({“results”: {$elemMatch {“product”: “abc”, “score”: 7}}})
2019-10-08T11:58:57.935-0700 E QUERY [js] uncaught exception: SyntaxError: missing : after property id :
@(shell):1:40

Doh - the error message actually told me what my mistake was: missing a colon after “$elemMatch”

problem solved

Hi @Joseph_Sloan_68624,

I’m glad your issue got resolved, if you have any other query please feel free to get back to us.

Happy Learning :slight_smile:

Thanks,
Shubham Ranjan
Curriculum Support Engineer