尝试通过Node(Mongoose表示ODM)将长字符串插入Mongodb,失败导致标题中提到的错误。
尝试通过Terminal,MongoDB Compass插入字符串,但是没有运气。
driver: true,
name: 'MongoError',
index: 0,
code: 17280,
errmsg:
'WiredTigerIndex::insert: key too large to index, failing 1719
需要插入字符串而不会丢失任何索引。 运行Mongo 4.0.3
答案 0 :(得分:2)
使用以下方法在该键上创建哈希索引:
db.collection.createIndex( { _id: "hashed" } )
现在它已成功插入。但是我们还有其他解决方案吗?