我试图使用 mongoimport 将 json 文件导入 mongodb。
json 文件被格式化为每行一个文档,例如:
{"type":"Feature","id":"feature0","geometry":{},"properties":{}}
{"type":"Feature","id":"feature1","geometry":{},"properties":{}}
我mongoimport --db mydb --collection mycollection data.json
在命令行上使用,得到:
2015-04-24T23:48:09.351+0800 connected to: localhost
2015-04-24T23:48:09.495+0800 imported 4085 documents
但是当我使用 mongo shell 并尝试时,db.mycollection.find().count()
我得到了 8170。文件数量增加了一倍。
然后我尝试查找带有“id”(不是“_id”)的文档,除了“_id”之外,我得到了两个相同的结果。
那么为什么文件被保存了两次呢?