finding a record with dot notation is possible via mongo shell for example:
db.events.find({'events.eid':307215649389788})
I’m trying to achieve the same thing with java drivers, problem is:
- db.getCollection(collectionName).find(query) – expects query as a DBObject.
- when creating DBObject with ‘events.eid’ as key, the constructor adds “” so I get the following result : “‘events.eid'” as key which won’t work (also in shell).
how can I overcome this?
Not quite sure what you’re trying, but this works:
You need to use double quotes (
") with Java strings so if you’re using single quotes that’s your problem.