I've got a single document in a collection:
{
_id: ObjectId("508836afea5cea2ccec11a0d"),
created_at: 1348657869.204,
name: "Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx Abcdefghijklmnopqrstuvwx"
}
I can find it with
find({"created_at":1348657869.204})
but
find({"name":"Abcd...<actual name here>...uvwx"})
returns no results. Is there a length limit to the field in the query?
In MongoDB, the limit() method limits the number of records or documents that you want. It basically defines the max limit of records/documents that you want. Or in other words, this method uses on cursor to specify the maximum number of documents/ records the cursor will return.
Working with MongoDB and ElasticSearch is an accurate decision to process millions of records in real-time. These structures and concepts could be applied to larger datasets and will work extremely well too.
As for the logical condition, there are String Aggregation Operators that you can use $strLenCP operator to check the length of the string. If the length is $gt a specified value, then this is a true match and the document is "kept". Otherwise it is "pruned" and discarded.
You can extract the value of a field by appending that field's name to your query when using findOne() .
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}))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With