无法在mongodb中创建索引,“键太大而无法建立索引"; [英] Cannot create index in mongodb, "key too large to index"
本文介绍了无法在mongodb中创建索引,“键太大而无法建立索引";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在mongodb中创建具有1000万条记录但出现错误的索引
I am creating index in mongodb having 10 million records but following error
db.logcollection.ensureIndex({"Module":1})
{
"createdCollectionAutomatically" : false,
"numIndexesBefore" : 3,
"ok" : 0,
"errmsg" : "Btree::insert: key too large to index, failing play.logcollection.$Module_1 1100 { : \"RezGainUISystem.Net.WebException: The request was aborted: The request was canceled.\r\n at System.Net.ConnectStream.InternalWrite(Boolean async, Byte...\" }",
"code" : 17282
}
请帮助我如何在mongodb中创建索引
Please help me how to createindex in mongodb,
推荐答案
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"})
或
db.logcollection.createIndex({"Module":"text"})
这篇关于无法在mongodb中创建索引,“键太大而无法建立索引";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文