I\'ve got a single document in a collection:
{
_id: ObjectId(\"508836afea5cea2ccec11a0d\"),
created_at: 1348657869.204,
name: \"Abcdefghijklmnopqrstuvw
The limit you are encountering is the maximum line buffer size in the mongo
shell, which is 4096 bytes as at MongoDB 2.2.1. If you try pasting your example in the mongo
shell you should notice that you cannot add any characters beyond the line limit.
If you execute this query from a language driver you will not have this issue.
You could also workaround this in the mongo
shell by loading the query from a JavaScript file specified on the command line:
mongo longname.js
Or by creating a long string in the mongo
shell programmatically:
// Longname will be 5000 characters
var longname = '';
for (i = 0; i < 200; i++) {
longname += 'Abcdefghijklmnopqrstuvwx ';
}
db.foo.insert({
_id: ObjectId("508836afea5cea2ccec11a0d"),
created_at: 1348657869.204,
name: longname
});
printjson(db.foo.findOne({name: longname}))