@andrewnessinjim
I encountered the same problem in the past. Contrary to what DHz noted, you are using the proper syntax, but you are bumping up a MongoDB limitation.
It absolutely is possible to have a field name with a dot in it, as shown below:
rs0:PRIMARY> db.test.find();
{ "_id" : ObjectId("5c47c74cb4e35a0c30421fd2"), "name" : "Tom", "address.zip" : 90210 }
The above can be queried by “name” but not by “address.zip”. The problem is that whenever a dot appears in the query, MongoDB assumes that the leftmost portion is the name of a hash and the rightmost portion is a key in the hash. Essentially, you are only searching on a document with the schema:
{ address: { zip: "21019" }
And that is not the shape of your document, so there are no results. MongoDB does not complain when adding field names that include . or $ characters, but they are not supported. In practice, you can store the data with no problem but will run into problems querying the data.
The common workaround is to avoid using those characters and use the unicode character equivalent, which makes the field name look like it contains a . or $, but actually it’s a different character code that MongoDB will not treat differently than other text.
A more cringeworthy way would be to not filter on the field at all (possibly returning all documents) and filter client-side. There are obvious performance implications, but it is an option.
If you really wanted to make it work, you can probably store a function in MongoDB. That function can then be used as part of a map-reduce aggregation component. Since you are writing the JavaScript code in the server-side function, you can have it check for a field name with a dot in it easily enough. I am sure that running custom JavaScript would pretty much nullify MongoDB’s automatic optimizations, but if you needed to do a query against a large data set from a slow client, keeping all of the processing and data server-side would make sense.
In summary, don’t use field names with . or $ in them unless you are looking for a fun challenge. 