error in monogdb “errmsg” : "WiredTigerIndex::insert: key too large to index, failing

瘦欲@ 提交于 2020-01-03 17:12:43

问题


I'm creating a index in mongo:

db.table.createIndex({"chr" : 1, "Start" : 1, "End" : 1, "Ref" : 1, "Alt" : 1}) 

It runs for some time and gives an error msg:

error in monogdb "errmsg" : "WiredTigerIndex::insert: key too large to index, failing

How do I fix this error?


回答1:


In MongoDB, since 2.6, the total size of an index entry must be less than 1024 bytes. Documentation here

In other terms, at least one of your documents has a large value in one of the field you are trying to index.

It's not a good idea in general to index very large values like that because it creates a big index which is less efficient compared to a smaller one and it takes more space in RAM which could be put to better use on a MongoDB node.

You could use this : mongod --setParameter failIndexKeyTooLong=false.

But it doesn't look like a good idea. If you have a large text to index, you should consider using the Full Text index or you could use a Hashed index.




回答2:


This can also be caused by having both a text index and a standard index for the same field. By deleting one of them you will be able to resolve this issue.



来源:https://stackoverflow.com/questions/43342082/error-in-monogdb-errmsg-wiredtigerindexinsert-key-too-large-to-index-fa

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!