No results for simple nested field query on Mongo 6

I have an Atlas cluster that I have been using for quite a while now and never had any issues. Over the weekend I installed MongoDB 6 locally to validate some data before it went on to Atlas. When I query my data and I try to filter by any nested field, there are no results. It will only return results for top level fields.
If I click on the Schema tab, and expand one of the nested fields and click on a value, it populates the filter for the query but upon searching it also returns no results. I can see the fields there but haven’t found any way of querying them yet.

My data has docs that look like this:

  _id: "FupuYjXeWooeTV0dEBE",
  timestamp: 1667507338,
  group: "VXF",
  tags: {
    format: "binary",
    version: "0.1.0",
    action: "store"
  data: ""

An example query looks like

{ 'tags.action': 'store' }

but that returns no results. {‘tags.action’: {$exists: true}} returns no results also…

If anyone has any troubleshooting recommendations I would greatly appreciate it!

Thank you

The problem turned out to be that I was inserting them as bson.E instead of bson.M from golang, and although the nested fields were showing up as expected in Compass, behind the scenes they were a different type, so I just recreated the collection and made sure to insert the whole object and nested fields as bson.M.


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