json - Mongoimport JSON文件错误: "BSON representation of supplied JSON array is too large: code FailedToParse: Date expecting integer milliseconds"

标签 json mongodb

我正在尝试使用以下命令将 json 文件导入数据库:

mongoimport --db db_name --collection collection_name file.json --jsonArray

但它不起作用,我收到此错误:

Tue Oct 21 15:42:20.176 check 0 0
Tue Oct 21 15:42:20.176 imported 0 objects
Tue Oct 21 15:42:20.176 ERROR: encountered 1 error(s)

我正在使用 MongoDB 2.4.9。接下来我可以尝试什么?

编辑

-vvvv 添加到命令中会产生以下结果:

Tue Oct 21 16:02:48.582 creating new connection to:127.0.0.1:27017
Tue Oct 21 16:02:48.583 BackgroundJob starting: ConnectBG
Tue Oct 21 16:02:48.584 connected connection!
connected to: 127.0.0.1
Tue Oct 21 16:02:48.584 ns: ip.ip_data
Tue Oct 21 16:02:48.585 filesize: 3526
Tue Oct 21 16:02:48.585 User Assertion: 13293:BSON representation of supplied JSON array is too large: code FailedToParse: FailedToParse: Date expecting integer milliseconds: offset:211

最佳答案

当您使用jsonArray时数组总大小必须小于 16MiB,否则您将收到该错误。您实际上正在执行批量插入,其中包含数组的单个文档作为插入发送,服务器将此解释为每个数组元素的插入,但总数不能大于 largest permissible BSON document

如果你把它分成更小的数组并导入它们,你就可以了,或者你可以使用一些代码来展开数组并直接导入结果。

关于json - Mongoimport JSON文件错误: "BSON representation of supplied JSON array is too large: code FailedToParse: Date expecting integer milliseconds",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26495085/

相关文章:

json - Mongo-go-driver 从插入结果中获取 objectID

php - 一个键的 JSON 求和值,其中有多个具有相同名称的键 PHP

java - Volley 请求队列返回 null

mongodb - 如何对数组字段中的子文档进行排序?

mongodb - 执行 mongodump 后 Mongod 服务崩溃

javascript - mongodb : TableRow. TableRow 不是构造函数

json - 问题是 "method' 对象不可迭代。我正在做一个小型 Django 应用程序

javascript - 如何在javascript中将字符串数据转换为Geojson

mongodb - 过滤集合但按内部属性排序

node.js - 如何检索包含某些参数排除在 mongo 的嵌套数组中的文档?