问题
I am currently working with mongoDB trying to index quite a large database. It has a field in every document called "content" that is of varying length. I have tried indexing it once, it ran for 2 hours, completed the indexing, but didn't build it because it came across something larger than 1024 bytes. I tried reading the limits manual, but I am not sure I 100% understand what these limits mean. Is it the "content" field that can be max 1024 bytes? Like so:
{ "Content" : "Can this be max 1024 bytes?" }
Or have I completely misunderstood this?
https://docs.mongodb.com/manual/reference/limits/
回答1:
The documentation says:
The total size of an index entry, which can include structural overhead depending on the BSON type, must be less than 1024 bytes.
You are indexing the values of the field "Content" so you understood it right. Each value of the field "Content" has to stay below 1024 bytes per indexed document.
Some bytes are reserved depending on the data type to store meta values. For example ff the value is a String, the length and the enconding are overhead values that also need to fit into the 1024 bytes so you have less remaining bytes your actual content. So try to stay below 1000 bytes to be save.
{ "Content" : "this value must stay below 1024 bytes!" }
来源:https://stackoverflow.com/questions/45653676/mongodb-index-limits