Mongodb导入具有多个文档的单个json文件

时间:2014-02-06 16:25:41

标签: json mongodb mongoimport

mongo db的新手。我有一个包含多个文档的json文件。

当我尝试通过mongoimport上传文件时,该文件被视为要创建的单个文档,因为有多个文档要通过同一文件创建。

以下是导入命令。

mongoimport --db mydb --collection testData --type json --file var/www/html/orders.json --jsonArray

运行此命令会引发以下错误:

exception:JSONArray file too large

2 个答案:

答案 0 :(得分:2)

从MongoDB文档开始,在发布stackoverflow之前总是引用文档:

  

- jsonArray   在2.2版中更改:文档大小限制从4MB增加到16MB。

     

接受在单个JSON数组中导入用多个MongoDB文档表示的数据。

     

与mongoexport --jsonArray结合使用,以导入作为单个JSON数组编写的数据。仅限进口16 MB或更小。

答案 1 :(得分:0)

Mongoimport用于将JSON文件上传到Mongodb。文件应采用格式良好的方式。 MongoDB将限制为16MB文件。

mongoimport --host hosturl --port 27017 --username uname --password pwd --   collection collname --db marketing --file filepathwithFilename

Example Refference

相关问题