MongoDB插入文档时出错,我该如何解决?

时间:2018-11-07 07:44:27

标签: mongodb

我一直在尝试通过命令提示符将JSON文件导入mongoDB,但是得到的输出显示插入文档时出错。

C:\Users\chery\Documents\NUS Y2 Sem 1 Modules\BT2102\Tutorials>mongoimport --db school --collection students students.json
2018-11-07T15:37:30.974+0800    connected to: localhost
2018-11-07T15:37:31.210+0800    num failures: 50
2018-11-07T15:37:31.211+0800    error inserting documents: multiple errors in bulk operation:
  - E11000 duplicate key error collection: school.students index: _id_ dup key: { : 2 }
  - E11000 duplicate key error collection: school.students index: _id_ dup key: { : 3 }
  - E11000 duplicate key error collection: school.students index: _id_ dup key: { : 4 }
  - E11000 duplicate key error collection: school.students index: _id_ dup key: { : 5 }
  - E11000 duplicate key error collection: school.students index: _id_ dup key: { : 1 }
  - E11000 duplicate key error collection: school.students index: _id_ dup key: { : 0 }
  - E11000 duplicate key error collection: school.students index: _id_ dup key: { : 6 }
  - E11000 duplicate key error collection: school.students index: _id_ dup key: { : 7 }
  - E11000 duplicate key error collection: school.students index: _id_ dup key: { : 10 }
  - E11000 duplicate key error collection: school.students index: _id_ dup key: { : 8 }
  - E11000 duplicate key error collection: school.students index: _id_ dup key: { : 12 }
  - E11000 duplicate key error collection: school.students index: _id_ dup key: { : 13 }
  - E11000 duplicate key error collection: school.students index: _id_ dup key: { : 11 }
  - E11000 duplicate key error collection: school.students index: _id_ dup key: { : 14 }
  - E11000 duplicate key error collection: school.students index: _id_ dup key: { : 15 }
  - E11000 duplicate key error collection: school.students index: _id_ dup key: { : 16 }
  - E11000 duplicate key error collection: school.students index: _id_ dup key: { : 17 }
  - E11000 duplicate key error collection: school.students index: _id_ dup key: { : 18 }
  - E11000 duplicate key error collection: school.students index: _id_ dup key: { : 9 }
  - E11000 duplicate key error collection: school.students index: _id_ dup key: { : 19 }
  - E11000 duplicate key error collection: school.students index: _id_ dup key: { : 20 }
  - E11000 duplicate key error collection: school.students index: _id_ dup key: { : 23 }
  - E11000 duplicate key error collection: school.students index: _id_ dup key: { : 24 }
  - E11000 duplicate key error collection: school.students index: _id_ dup key: { : 22 }
  - E11000 duplicate key error collection: school.students index: _id_ dup key: { : 26 }
  - E11000 duplicate key error collection: school.students index: _id_ dup key: { : 25 }
  - E11000 duplicate key error collection: school.students index: _id_ dup key: { : 27 }
  - E11000 duplicate key error collection: school.students index: _id_ dup key: { : 29 }
  - E11000 duplicate key error collection: school.students index: _id_ dup key: { : 28 }
  - E11000 duplicate key error collection: school.students index: _id_ dup key: { : 21 }
  - E11000 duplicate key error collection: school.students index: _id_ dup key: { : 30 }
  - E11000 duplicate key error collection: school.students index: _id_ dup key: { : 31 }
  - E11000 duplicate key error collection: school.students index: _id_ dup key: { : 33 }
  - E11000 duplicate key error collection: school.students index: _id_ dup key: { : 35 }
  - E11000 duplicate key error collection: school.students index: _id_ dup key: { : 34 }
  - E11000 duplicate key error collection: school.students index: _id_ dup key: { : 36 }
  - E11000 duplicate key error collection: school.students index: _id_ dup key: { : 37 }
  - E11000 duplicate key error collection: school.students index: _id_ dup key: { : 38 }
  - E11000 duplicate key error collection: school.students index: _id_ dup key: { : 32 }
  - E11000 duplicate key error collection: school.students index: _id_ dup key: { : 40 }
  - E11000 duplicate key error collection: school.students index: _id_ dup key: { : 39 }
  - E11000 duplicate key error collection: school.students index: _id_ dup key: { : 41 }
  - E11000 duplicate key error collection: school.students index: _id_ dup key: { : 43 }
  - E11000 duplicate key error collection: school.students index: _id_ dup key: { : 44 }
  - E11000 duplicate key error collection: school.students index: _id_ dup key: { : 46 }
  - E11000 duplicate key error collection: school.students index: _id_ dup key: { : 47 }
  - E11000 duplicate key error collection: school.students index: _id_ dup key: { : 42 }
  - E11000 duplicate key error collection: school.students index: _id_ dup key: { : 45 }
  - E11000 duplicate key error collection: school.students index: _id_ dup key: { : 48 }
  - E11000 duplicate key error collection: school.students index: _id_ dup key: { : 49 }

2018-11-07T15:37:31.211+0800    imported 0 documents

我可以知道这里的问题是什么,如何纠正该错误?

真的很感谢您的帮助!

0 个答案:

没有答案