Querying nested array "not working"

Hi folks, I’m not really sure why my simple query is not working. I just loaded a new collection into my atlas database. And a very simple filter inside compass is not working.

my collection has a nested object platform

when I use { “platform” : { “_id” : 1} as a filter, no results are found. It does not matter what property I use.

Filters are also not matching any other array elements such as genres. Am I missing something very obvious and silly here?
Thanks

Just wanted to add another point, the data is being loaded via java with the mongo driver using pojo codec.

If I insert one document via the atlas ui, using the exact same structure, then the query finds the data. Not sure if there’s a problem with the pojo codec, but the data entered manually does not appear to be any different from the one in the collection.

You need to use dot notation.

When you write:

{ "platform" : { "_id" : 1 } }

what you really mean is that you want platform to be equal to the object { “_id” : 1 }.

An object will be equal to another if and only if, it has the same fields and values, in the same order.

With the dot notation you are able to write

{ "platform._id" : 1 }

which indicate that you want an object named platform which has a field named _id equals to 1.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.