Let say I have following Java org.bson.Document
Document innerDoc = new Document();
innerDoc.put("field.with.dot", "something");
Document doc = new Document("inner", innerDoc);
When I insert doc into I got "The dotted field 'field.with.dot' is not valid for storage", I checked the documentation that mongoDB doesn't allow dotted fields in nested Document.
how to I get around with this? because the Document is generated dynamically, so It may have dotted fields in several levels deep. Noted: I don't want to replace the "dot" symbol.
Is it possible to break down the dotted field into nested fields?
{"inner": {
"field": {
"with": {
"dot": "something"
}
}
}
}
You have to build nested documents
Or you can do the same in a single instruction :