我得到以下错误(转储MongoDB 3.2)(恢复MongoDB 3.4):

Failed: ngivr-dev.ledgerhelpers: error creating indexes for ngivr-dev.ledgerhelpers: **createIndex error:** **The field 'safe' is not valid for an index specification.** Specification: **{ unique: true, name: "ledgerId_1", safe: null, ns: "ngivr-dev.ledgerhelpers", background: true, key: { ledgerId: 1 } }**

看起来安全索引为空.但我如何将其用于MongoDB 3.4?3.2没问题.

推荐答案

safe=true不是索引规范.

在以前版本的MongoDB(低于3.4)中,可以添加额外的索引规范.这些都是由特定的司机使用的.

在3.4中,mongodb增加了对索引规范的验证:

Ensuring that the specified index options are valid. Previous versions ignored invalid options.

这就是为什么你会犯这个错误.

正如kz_sergey在他的回答中所说,你可以使用--noIndexRestore来实现mongorestore,这应该很好.

Mongodb相关问答推荐

会话的Mongo-go驱动程序版本.Copy()

我无法将文档发送到我的MongoDB集合,因为它告诉我使文档无效

无法通过管理邮箱/密码身份验证注册/登录新用户帐户(类型错误:加载失败)

Mongo聚合的具体格式

如何在 mongodb 中将一个方面的结果合并到一个有条件的列表中?

Golang:如何判断 collection.Find 是否没有找到任何文件?

如何在 MongoDB 中已经存在的 slug 中添加一个随机数?

在我的查询中使用 populate() 时的 MongoDB createIndex()

Nestjs中不同语言数据的mongodb聚合代码

.NET 4 中是否有 mongodb C# 驱动程序支持 System.Dynamic.DynamicObject?

Mongoose 的保存回调是如何工作的?

MongoDB 批处理操作的最大大小是多少?

如何根据其他字段添加条件模式?

MongoDb 数据库与集合

带有 Java 驱动程序的 MongoDB 聚合

错误:Could not connect to any servers in your MongoDB Atlas cluster

没有参考选项的mongoose填充字段

获取 mongodb 中所有唯一标签的列表

从 mongo 结果中删除 _id

判断字段是否存在于数组的子文档中