Find deeply nested data in MongoDB

Hi!

My current aim is to find all securities that have Source = Manual on a security field (e.g. Instrument_Name, Instrument_InstrumentType) this means a particular field has been manually updated by user. The problem comes from the fact that there are lots of Sources ( e.g. GSMApi, OpenFigi) and lots of security fields on each of the sources. I am trying to narrow this down, but cannot seem to find a proper query to do so. Also I’m not exactly good with queries on MongoDB and anything I’ve tried so far is either 0 results fetched or an error. I believe these are not arrays, but rather nested documents. I have included current data structure in a screenshot. Also below fetches single result by using full path -

db.getCollection(‘security-data’).find({“SourceFields.RemotePlus.Instrument_Issue_Issuer_Name.Source”: ‘Manual’})

However RemotePlus.Instrument_Issue_Issuer_Name is not a constant, the manual update can happen anywhere, on any source and any of its field (even multiple) this is where I’m stuck.

below is current data structure -

Thanks!

Hi @Ed_Motor - Welcome to the community :wave:

However RemotePlus.Instrument_Issue_Issuer_Name is not a constant, the manual update can happen anywhere, on any source and any of its field (even multiple) this is where I’m stuck.

Can you provide the following information:

  1. MongoDB version in use.
  2. 4-5 sample document(s) including a mix of where RemotePlus.Instrument_Issue_Issuer_Name varies in different level fields.
  3. Expected output of the 4-5 sample documents provided.

Regards,
Jason