gpt4 book ai didi

json - mongoimport json文件错误

转载 作者:可可西里 更新时间:2023-11-01 10:04:05 25 4
gpt4 key购买 nike

我正在尝试使用以下命令将我的 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文件错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26495085/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com