I have a document that goes like this:
{
"_id" : NumberLong(111603),
"max" : "Created At",
"document" : {
"_id" : ObjectId("54ad61013e016de5798c0582"),
"testfield1" : "ISUZU (GM)",
"Model - Range" : "N-series",
"testfield2" : "N NQR 75",
}
}
And I would like to aggregate on the collection containing a number of these documents. I'm having an issue with the "Model - Range" in the $project step. Currently I am using
db.AE.aggregate([
{"$project":{
"Make":"$document.testfield1",
"Model":"$document.testfield2",
"_id":0,
"Group": "$document['Model - Range']"
}}
]);
But for some reason, MongoDB is completely ignoring the Group field and only adding the other two fields.
Is there a way to address fields with spaces/special characters in them when projecting in MongoDB aggregation framework?
consecutiveCamelCasedNamesbecause we have experience and we know what works and what does not.