Is there a limit on the length of field values ​​in mango queries?

I have one document in the 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"}) 

does not return results. Is there a length limit for a field in a request?

+4
source share
1 answer

The limit you encounter is the maximum size of the string buffer in the mongo shell, which is 4096 bytes , as in MongoDB 2.2.1. If you try to paste your example into the mongo shell, you should notice that you cannot add any characters outside the line.

If you run this query from the language driver , you will not have this problem.

You can also work around this in the mongo shell by loading the request from the JavaScript file specified on the command line:

  mongo longname.js 

Or by creating a long line 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})) 
+15
source

Source: https://habr.com/ru/post/1443573/


All Articles