Anop Singh Ranawat
Anop Singh Ranawat

Reputation: 79

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

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?

Upvotes: 7

Views: 10091

Answers (2)

Gabriel Fair
Gabriel Fair

Reputation: 4264

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.

Upvotes: 0

Maxime Beugnet
Maxime Beugnet

Reputation: 822

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.

Upvotes: 11

Related Questions