Cannot create index in mongodb, “key too large to index”

MongoDB will not create an index on a collection if the index entry for an existing document exceeds the index key limit (1024 bytes). You can however create a hashed index or text index instead:

db.logcollection.createIndex({"Module":"hashed"})

or

db.logcollection.createIndex({"Module":"text"})

Leave a Comment