mongoDB索引限制 [英] mongoDB Index Limits

查看:118
本文介绍了mongoDB索引限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在与mongoDB合作,尝试为相当大的数据库建立索引.每个文档中都有一个称为内容"的字段,其长度是可变的.我试过一次索引,它运行了2个小时,完成了索引编制,但是由于它遇到了大于1024字节的东西,所以没有构建它.我尝试阅读极限手册,但不确定100%理解这些极限的含义. 内容"字段最多可以是1024个字节吗?像这样:

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/

推荐答案

文档说:

索引条目的总大小(小于BSON类型,可能包括结构开销)必须小于1024个字节.

The total size of an index entry, which can include structural overhead depending on the BSON type, must be less than 1024 bytes.

您正在索引字段"Content"的值,因此您理解正确.每个索引文档的字段"Content"的每个值都必须保持在1024个字节以下.

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.

根据数据类型保留一些字节来存储元值.例如,如果ff的值是一个String,则长度和enconding是开销值,这些值也需要适合1024个字节,因此实际内容的剩余字节数更少.因此,请尝试将其保存在1000个字节以下.

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!" }

这篇关于mongoDB索引限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆