how to import large json file into mongodb using mongoimport?
Asked Answered
D

1

7

I am trying to import the large data set json file into mongodb using mongoimport.

mongoimport --db test --collection sam1 --file 1234.json --jsonArray

error:
2014-07-02T15:57:16.406+0530 error: object to insert too large
2014-07-02T15:57:16.406+0530 tried to import 1 objects
Daisy answered 2/7, 2014 at 17:17 Comment(6)
What's your file look like?Tranche
Mongo has a 16Mb limit for a single JSON doc. You've likely got too much data. (Or shouldn't be using --jsonArray.)Hathcock
my json file size 17MB. inside single document is occupied >16MB of data. How I can parse this data other than mongoimport( cos i am already facing issue with mongoimport).Daisy
If you have JSON documents larger than 16MB, you'll need to refactor those into smaller documents. The maximum document size limit is imposed by the MongoDB server, not mongoimport. As noted in an earlier comment, you probably shouldn't be using --jsonArray as the limit for the array is 16MB; splitting that into one line per array element may fix your import issue.Uniformed
@MoreThanFive do you know how to do it. please check this question. #33035285Clayborne
@MoreThanFive : no luck yetDaisy
A
13

Please try add this option: --batchSize 1

Like:

mongoimport --db test --collection sam1 --file 1234.json --batchSize 1

Data will be parsed and stored into the database batchwise

Attending answered 29/11, 2015 at 0:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.