MongoDB 2.4.9 密钥太大

MongoDB 2.4.9 key too large

我收到这些错误:

ERROR: key too large len:2448 max:1024

[conn89] unindex failed (key too big?)

我正在使用 MongoDB 2.4.9。知道如何修复这些错误吗?

此错误消息存在 Mongo数据库问题

SERVER-11209: ERROR: key too large len:6597 max:1024 6597

主要问题有完整的解释

SERVER-5290: fail to insert docs with fields too long to index, and fail to create indexes where doc keys are too big

主要问题是索引键的大小有限。如果您的索引键大于 1024,即使成功插入,文档也无法被索引并且在某些查询中将无法在 Mongo 中找到。

您必须修改索引并使用更小的键。

根据实际情况,有几种方法可以解决这个问题。看我的回答: