Insert large record into mongodb using mongo shell

我的未来我决定 提交于 2021-02-15 07:50:55

问题


I'm trying to insert large polygon array into my collection. I'm using following command to insert the data...

db.geoPolygonData.insert({"polygonName":"location1", "polygons":{"type":"Polygon", coordinates:[[[ 17.60083012593064, 78.18557739257812], [ 17.16834652544664, 78.19381713867188], [ 17.17490690610013, 78.739013671875], [ 17.613919673106714, 78.73489379882812],[ 17.60083012593064, 78.18557739257812]]]}});
WriteResult({ "nInserted" : 1 })
  • Problem: when the polygon array size is too large then not able paste that in the insert command.
db.geoPolygonData.insert({"polygonName":"location1", "polygons":{"type":"Polygon", coordinates:[[27.24391676007466, 77.99706560813125], [27.24663657232702, 77.99603771498144], [27.247562169041, 77.99579619785604], [27.24812715892217, 77.9953496989439], [27.24815137812172, 77.99495972468578], [27.24786408813674, 77.9942950687252], [27.24728295413829, 77.99401316495602], [27.24691626810016, 77.99409211782215], [27.24630787932104, 77.99434214769431], [27.24578183050557, 77.99445233957894], [27.24506545801119, 77.99455743098659], [27.24436725351516, 77.99441937620895], [27.24428512657685, 77.99339215109099], [27.24416758939267, 77.99335786813789], [27.24388134647987, 77.99340468780039], [27.24364577274164, 77.99335946000515], [27.24338072207595, 77.99339127980087], [27.24307924134828, 77.99349996041506], [27.24289895965795, 77.99347178104993], [27.24242531545428, 77.99349801394814], [27.24226589308678, 77.9934703935053], [27.24224091007617, 77.99333740322909], [27.24262872921169, 77.9924448883617], [27.24346377039268, 77.99080931883213], [27.24277480621489, 77.99016819114682], [27.24236626279172, 77.98975251327597], [27.24184037267633, 77.98896787149644], [27.24208060195639, 77.98879527249848], [27.24264732258803, 77.98832005673326], [27.2427620622403, 77.98815966761026], [27.24277061841023, 77.98775903791018], [27.24286204153501, 77.9872244087011], [27.24289782642137, 77.9868517488547], [27.24293484509637, 77.98658420129162], [27.24290480133503, 77.98652502094515], [27.24277087525858, 77.98644360578182], [27.24250037654928, 77.98624178714861], [27.24216696692127, 77.98605385611691], [27.24201267904537, 77.98594854734944], [27.24187751713501, 77.9857620219303], [27.24159072245221, 77.98534572280121], [27.24138041126056, 77.98493146821534], [27.24194752676157, 77.98460024188113], [27.24212161328115, 77.98442975868801], [27.24185542511326, 77.98402568725903], [27.24169750036504, 77.98376461240707], [27.24140970399648, 77.9833949934572], [27.24088707995773, 77.98278171147012], [27.24062363684074, 77.98240866091682], [27.24088987367768, 77.9822027094119], [27.24115026007457, 77.9818989504684], [27.24134493499909, 77.98169996525266], [27.24181036156287, 77.98182778642682], [27.24182434241625, 77.98154408370043], [27.24177771643389, 77.981125603911], [27.24179981514432, 77.98083324019257], [27.24173090014172, 77.98071599666811], [27.24177489872516, 77.98051299053564], [27.24188309507776, 77.98027618643594], [27.24195427841228, 77.98028696177776], [27.24196900495651, 77.98034061874148], [27.2420479295497, 77.98036047793835], [27.24213932024148, 77.98016761203432], [27.24228905710167, 77.97984314018316], [27.24258173204895, 77.97914074792912], [27.24321086306847, 77.9794060864327], [27.24350938865228, 77.97880149586724], [27.24358755785651, 77.97885684431792], [27.24378053236036, 77.97836484552957], [27.24366157829446, 77.97836167565461], [27.24377996811734, 77.97801860652774], [27.24384208985404, 77.9777095477021], [27.24369254765399, 77.97765229839226], [27.24382547432796, 77.9769989014064], [27.24388211764866, 77.97657428762763], [27.24390892597918, 77.97606010329555], [27.24428920227233, 77.9760879843636], [27.24419894168467, 77.97548190529714], [27.24408432732331, 77.97527466974142], [27.24337190002105, 77.97407499443753], [27.24333922665217, 77.97374565668366], [27.24261983184003, 77.97361998718297], [27.24235020142166, 77.97361281395445], [27.24166139609085, 77.97354122514088], [27.24163740551786, 77.97317661395424], [27.24070275998563, 77.97309849000847], [27.24016878354814, 77.97302214698475], [27.24015063440687, 77.97238250053793], [27.24006658996276, 77.97185650683522], [27.24004089870061, 77.97157175117869], [27.24000424469154, 77.97105589519276], [27.23973197596943, 77.97117294032903], [27.23962643244647, 77.9712855392159], [27.23934303014902, 77.97155320020754], [27.23919046971809, 77.97163791691194], [27.23890483621163, 77.97183472028493], [27.23793384110247, 77.9714278759281], [27.23791915121764, 77.97134668732562], [27.23796719530922, 77.97113935224066], [27.23804486949654, 77.97065761379115], [27.23804420052079, 77.97050224647363], [27.2380522150586, 77.97031160139083], [27.23770525776551, 77.9702091736292], [27.23712180256475, 77.97003388585033], [27.23645177225287, 77.96982523100517], [27.23605855024003, 77.96965943908992], [27.23608137700895, 77.96933159768798], [27.2360918246972, 77.96883920343133], [27.23603734752186, 77.96878893355198], [27.2358053785725, 77.96868956611098], [27.23565177194435, 77.96863666440206], [27.23556642021527, 77.96854562890074], [27.23537476146519, 77.96841626348875], [27.23522284841485, 77.96828351524798], [27.23511455216204, 77.96815192526456], [27.23500219649088, 77.9680246662129], [27.23489352361323, 77.96791082050332], [27.2347719202275, 77.96784545457116], [27.23466570711387, 77.96780268945206], [27.23471252266857, 77.96765302538556], [27.2340761691697, 77.96716566460886], [27.23389234509042, 77.96704094974878], [27.23364087509413, 77.96748699283201], [27.23331259700067, 77.96725192352372], [27.2334079345315, 77.96705916465518], [27.23281850210135, 77.96660412688988], [27.23273344656863, 77.96668619913619], [27.23243282901324, 77.96645630639951], [27.23213580006381, 77.96624426347921], [27.23129135296767, 77.96565376169849], [27.23045417510392, 77.96509452994871], [27.22967337141958, 77.96468326330394], [27.22948926242537, 77.96457186518343], [27.22914047490189, 77.96418093282234], [27.22888091296686, 77.96388556984002], [27.22858540191636, 77.96378897455655], [27.22831058224185, 77.96383938830616], [27.22804388081856, 77.96388114065904], [27.22775120771441, 77.9638378795061], [27.22740367930377, 77.96376209800862], [27.22675648634716, 77.9635984905796], [27.2261006112913, 77.96347016019317], [27.22559285694918, 77.9632791845895], [27.22513165169155, 77.96313826268813], [27.22485718621491, 77.9629845364143], [27.22455515187099, 77.9628212046522], [27.22420307170152, 77.96258553997579], [27.22406691814265, 77.96245766949579], [27.22390981196892, 77.96238250064044], [27.22375988517349, 77.96234302621373], [27.2234206610684, 77.96224972120102], [27.22310785618344, 77.96203285287488], [27.22292799082263, 77.96190826504457], [27.22230453809463, 77.96212253181022], [27.2224107774854, 77.96160166599452], [27.22159352090845, 77.96122499693422], [27.22171930137752, 77.96071796420925], [27.22168908067144, 77.96064615753836], [27.22167877979222, 77.96057044012998], [27.22151618066637, 77.96037974443419], [27.22126946759449, 77.96022676491796], [27.22096942447697, 77.96015669527112], [27.22025899461001, 77.96016896361162], [27.22014484750736, 77.96012600267605], [27.21990255214584, 77.96051456170167], [27.21985206171045, 77.96065079925681], [27.2197348443701, 77.96094059571483], [27.21928675017983, 77.96074234826042], [27.21895526695234, 77.96065813362198], [27.2187265039849, 77.96059438879095], [27.21870169683053, 77.96007894618809], [27.21851302794826, 77.95980768654744], [27.21823400232318, 77.95949409770859], [27.21828296399789, 77.95924243826661], [27.21833011616025, 77.95888866130005], [27.21846909508166, 77.95831985944943], [27.2185447803676, 77.95811772123702], [27.21881595020102, 77.9576766703609], [27.21870273910345, 77.95758935918295], [27.21872047406592, 77.95750107158179], [27.21852842682649, 77.95738948784111], [27.21870630270251, 77.95685721314206], [27.21854635139379, 77.95672872738318], [27.21834134627352, 77.95647923072106], [27.21822259534839, 77.95633665279307], [27.21817714830512, 77.95636394713932], [27.21793996833566, 77.95651078428196], [27.21769910404083, 77.95664421013346], [27.21747410056894, 77.95677805456684], [27.21718285909136, 77.95685467612577], [27.21698974929357, 77.9568872941336], [27.21691757893229, 77.95692310789576], [27.21616501315811, 77.95677008997329], [27.21586029938408, 77.95673319347618], [27.21570490571156, 77.95704638324507], [27.21548236703363, 77.95753308641565], [27.21533249791063, 77.95786638953417], [27.21522331114027, 77.95815195267147], [27.21510431895429, 77.95852600945611], [27.21496474985562, 77.95893502265513], [27.21480791252444, 77.95941014299767], [27.21454350393353, 77.96028180499641], [27.21453718099778, 77.96029938832348], [27.21393904923445, 77.95997293271769], [27.21402717455296, 77.96162162244295], [27.21402140620174, 77.96226936260713], [27.21404592542554, 77.96279808861533], [27.21410080075447, 77.9637669430382], [27.21409368653921, 77.96429039379774], [27.2140830539672, 77.96460518308498], [27.2141266185798, 77.96498353481704], [27.21412400877715, 77.96529409897698], [27.21413167723125, 77.96549399499717], [27.21392368226408, 77.96538641838274], [27.21280186582671, 77.96496618798521], [27.21242742567541, 77.96484976696418], [27.21213447029789, 77.96481981861358], [27.21196595963191, 77.96490854290111], [27.21170610236684, 77.96537647394946], [27.21142981925112, 77.9658705925539], [27.21088553390126, 77.96571860754503], [27.21053885073018, 77.96560292213167], [27.21021124198086, 77.96552324259734], [27.20999511525522, 77.96548916774981], [27.20990676685457, 77.96547523866558], [27.20956188828616, 77.96546166415936], [27.20944601809946, 77.96606208501102], [27.20943514158481, 77.96605612438955], [27.20943563421359, 77.9660840001905], [27.20926297016088, 77.96711778150592], [27.20886621281779, 77.96861598144132], [27.20853150733383, 77.96943245883226], [27.2083181600282, 77.97023218010102], [27.20722643588747, 77.97344246234586], [27.20606686389735, 77.97685498779262], [27.20566603930921, 77.97816663089377], [27.20508432004915, 77.97977518083036], [27.20433113649352, 77.98198260471948], [27.20347388901654, 77.98385887385953], [27.20238360330877, 77.98624360251489], [27.20079531086978, 77.98980280080488], [27.20070863244568, 77.98999702970562], [27.19953496978029, 77.99256575907215], [27.19921827036782, 77.99327608312015], [27.19862739042537, 77.99419204525896], [27.19804238413151, 77.99483306632364], [27.19793116302506, 77.99493214076203], [27.19792835390957, 77.99493158025571], [27.19792778621711, 77.99495090728823], [27.19793294665098, 77.99503423897268], [27.19829217947011, 77.9953965815679], [27.19814720784494, 77.99549696957438], [27.1976902548515, 77.99571546513178], [27.1973337383552, 77.99606087852536], [27.19675741396101, 77.99666661988743], [27.1965602583714, 77.99698079732647], [27.19641971125107, 77.99761594099729], [27.19647001167216, 77.9986022655353], [27.19654057916646, 77.99901234424416], [27.19672810375937, 78.00025968261251], [27.19668474355631, 78.00117251025878], [27.19668635033792, 78.00183807920907], [27.19662715928937, 78.0018231821443], [27.19616901593137, 78.00172660274932], [27.19494525792143, 78.00144090819816], [27.19420701841765, 78.00127027567977], [27.19330017993058, 78.00100639441423], [27.1925896814804, 78.0008568952528], [27.19261336580441, 78.00102792324468], [27.1928186888865, 78.00181428099327], [27.19311308584775, 78.00288697756035], [27.19424320038513, 78.00605848444471], [27.19271211245174, 78.00715318056528], [27.19239807865275, 78.00740362669076], [27.19294609999842, 78.00787321275676], [27.19295838369142, 78.00787853388606], [27.19305589146632, 78.00795657590562], [27.19316979649053, 78.00819477902972], [27.19324868220437, 78.00840098522298], [27.19347414427054, 78.00880190672376], [27.19354652763711, 78.00894138874327], [27.19353387048671, 78.00897654229037], [27.19357218749836, 78.00903968541331], [27.19365269122929, 78.00917051246111], [27.19371996599832, 78.00936309809202], [27.19377769079253, 78.00963085132561], [27.19386301643829, 78.00972187821192], [27.19402916741084, 78.00974408977997], [27.19414680655658, 78.01017761261784], [27.19422816672792, 78.0102685336467], [27.19429381974986, 78.01053650155765], [27.19439001066891, 78.0110448738458], [27.19442723954208, 78.01134313536367], [27.19436080462836, 78.01166522994305], [27.19428878304653, 78.01206259807842], [27.19411172169513, 78.01273221650678], [27.19389815476791, 78.01325443932943], [27.19370006457805, 78.01379482325157], [27.19344426732303, 78.01443569575433], [27.19311227281256, 78.01511444403447], [27.19276412881544, 78.01580606326293], [27.19252953004621, 78.01619904441438], [27.19235450116551, 78.01658919151583], [27.19214001205044, 78.01696940127546], [27.19201494920693, 78.01724997627316], [27.19199660590194, 78.01736483416869], [27.19192375622727, 78.01761575865827], [27.19183891554986, 78.01787079633924], [27.19177853328781, 78.01809543638203], [27.19177261000917, 78.01837034623654], [27.19175913835457, 78.01862730619285], [27.19175359626724, 78.01888447976], [27.191740601502, 78.01911926939088], [27.19177236837291, 78.01930202627338], [27.19182472467829, 78.01944984543302], [27.19222839158944, 78.01949621972656], [27.19292374898787, 78.01963031750947], [27.19304986474796, 78.01966921066577], [27.1933328603993, 78.01979219332732], [27.19366573670981, 78.01907355307247], [27.19382691520415, 78.0193263518824], [27.1943653841285, 78.02011285410013], [27.19493929013911, 78.02109553549504], [27.19507199631934, 78.02119672318948], [27.19471589288477, 78.02188811794144], [27.19445437233568, 78.02260868084464], [27.19416170256957, 78.02330177921094], [27.19422265419252, 78.02341877840179], [27.19450526276897, 78.02355950826873], [27.1949026092643, 78.02389855200583], [27.1954338071806, 78.02428557997797], [27.19632786795053, 78.024771147305], [27.19679772969668, 78.02505891869667], [27.19703183511416, 78.02450620588449], [27.19717534090439, 78.02447458716378], [27.19732830867871, 78.02437223496095], [27.19754463704749, 78.02390777438637], [27.1978248968908, 78.02305459672226], [27.19795522228246, 78.02289838871127], [27.19812692010631, 78.02266343385763], [27.19816226251501, 78.02263284673576], [27.19849869865996, 78.02234167658406], [27.19889097527965, 78.02255538823334], [27.19974654017136, 78.02298667784025], [27.20004673140548, 78.02304802515958], [27.20052605789732, 78.02326506528135], [27.20090869224813, 78.02355048778385], [27.20145804705544, 78.02383154088642], [27.20165304129033, 78.02398766442867], [27.20231303155933, 78.02428945829824], [27.20353317603095, 78.0247395005097], [27.20410059037587, 78.02491900239205], [27.20428649397797, 78.02500962431186], [27.20446452734626, 78.02460049086724], [27.20477716762556, 78.02408535888529], [27.20508034425109, 78.02364096228851], [27.20562754627147, 78.0229191760799], [27.20579074095631, 78.02271059962428], [27.20600572677554, 78.02230818586273], [27.20623331767811, 78.02205697456102], [27.20648488958961, 78.0217975352315], [27.20656047010335, 78.02160433936726], [27.20666910995794, 78.02134991488052], [27.20687911720588, 78.02117809514438], [27.2071068977458, 78.02091801030322], [27.2071345144938, 78.0207412672428], [27.20718745158633, 78.02049421193554], [27.20736803357932, 78.02021510260539], [27.20755110171973, 78.01982069151158], [27.20781223246168, 78.01911777799943], [27.20801431699518, 78.01820915529491], [27.2080829187487, 78.01797139339193], [27.20862926668913, 78.01793066171997], [27.20863591744945, 78.0180839233854], [27.20855057755293, 78.01946605056622], [27.2084680943173, 78.02071513384519], [27.20817098924697, 78.0225360712049], [27.20814805379635, 78.02267663474683], [27.20768828539918, 78.02555103134681], [27.20768022136127, 78.02560144294227], [27.20741174853267, 78.02700965523609], [27.2072518835516, 78.0285317279018], [27.20687149951069, 78.0299768310675], [27.20678770054831, 78.03022985514747], [27.20569171295186, 78.03353894212586], [27.2072627013746, 78.03389658195074], [27.20969242670459, 78.03454816009753], [27.2110378180948, 78.03470888265862], [27.2123735009829, 78.03458535493058], [27.21354750995567, 78.03459943976709], [27.21466423155667, 78.03432797421576], [27.2157144380108, 78.03419670140018], [27.21661296664191, 78.03374181033814], [27.2178820352888, 78.0330307014938], [27.21938323400994, 78.03259212920248], [27.22011778116002, 78.03238127967582], [27.22049548245858, 78.03216075614249], [27.22079061818152, 78.03208887623616], [27.22151512156164, 78.0319753800159], [27.22218175729402, 78.0316029231399], [27.2225685403382, 78.0313293860447], [27.22276154752585, 78.03121035762453], [27.22303308537854, 78.03112895925932], [27.22356106951116, 78.03093024989845], [27.22423025526267, 78.03080637052405], [27.22475516597244, 78.03074958714402], [27.22525258261855, 78.03049679063653], [27.22582545689592, 78.03042355355224], [27.22627830693191, 78.03041835932332], [27.22637939822247, 78.03049181751697], [27.22656594318347, 78.03048799605264], [27.22870202390565, 78.03077665493444], [27.22883043923698, 78.03070912625756], [27.22900547347382, 78.03068724133362], [27.2292605751705, 78.03063202165902], [27.22952360676366, 78.03057701668526], [27.22976808912851, 78.03064577525254], [27.23012570327217, 78.03061996198839], [27.23075427891809, 78.030539358199], [27.23121555812569, 78.03048972522578], [27.23143990068949, 78.03038928940437], [27.23172499306933, 78.03041476810502], [27.23200138708015, 78.03047551667753], [27.23234972650702, 78.03051158637116], [27.23254816620002, 78.03050808813641], [27.23265726365515, 78.03059980895866], [27.2334226214684, 78.03079808230991], [27.23412006832814, 78.03083474062036], [27.23475068740454, 78.03084295855741], [27.23514533109671, 78.03079361531215], [27.23530099476503, 78.02741374784027], [27.23577167449148, 78.02472798460923], [27.23614407920141, 78.0221815660897], [27.23517856079782, 78.02169831977125], [27.23461287124243, 78.02143892489497], [27.23416139935826, 78.02121812540022], [27.23392928480861, 78.02112752627612], [27.23383933507575, 78.02106739833258], [27.23337520132796, 78.02088176609456], [27.23297044624056, 78.02070217792479], [27.23251152132139, 78.02045899284201], [27.2320714634233, 78.02026070153794], [27.23162558100275, 78.01996461457453], [27.23147759145601, 78.01983634884273], [27.23111826773005, 78.01957366977976], [27.23005356930287, 78.01890583091986], [27.22926483297745, 78.01850286293163], [27.22889642798219, 78.01829320580805], [27.2274120560796, 78.01740104583057], [27.22693348922222, 78.01714848250697], [27.22673963718334, 78.01693910525711], [27.22405537843054, 78.01668031370892], [27.22135238994785, 78.01655416973723], [27.22110355014751, 78.01650308224704], [27.22044601822852, 78.016454722549], [27.22045262177788, 78.0161482622511], [27.22026363910624, 78.01608103898712], [27.22044875315399, 78.01503872021787], [27.22043709400727, 78.01447481143323], [27.22033538304079, 78.0138552236527], [27.21983028039209, 78.01280762539469], [27.21985478268253, 78.01259083623826], [27.21994682892811, 78.01218504282124], [27.22000987833954, 78.01183615871982], [27.219366441512, 78.01168570586593], [27.21833151595688, 78.01147590336807], [27.21806389748549, 78.01137550939198], [27.21765334699458, 78.01128014456796], [27.21747276815586, 78.01119096950168], [27.21711580725416, 78.01081747753793], [27.21680489960309, 78.0105162289342], [27.21695601763933, 78.00976146090736], [27.21711378371353, 78.00925093916776], [27.21725869972498, 78.0087844467447], [27.21754166601001, 78.00817078445093], [27.21771568383716, 78.00784416163899], [27.21898831840402, 78.00851825135908], [27.21975706020936, 78.00722377016045], [27.21984425602154, 78.007051019381], [27.21995147549836, 78.00691771640876], [27.22025561489147, 78.00636169498371], [27.22047869734048, 78.00634045253888], [27.22066495774837, 78.00625207325635], [27.22089519129137, 78.00605981752364], [27.22114149271854, 78.00625320538332], [27.22170636979913, 78.00570418167304], [27.22177075377924, 78.00578373270311], [27.22195481200734, 78.00595988493512], [27.22208252495177, 78.0060061183742], [27.22218682081596, 78.00600892088114], [27.22231536885935, 78.00601626615533], [27.22244664180072, 78.0060587044352], [27.22271233007343, 78.00615923012705], [27.22280486001887, 78.00622397418417], [27.22280905683417, 78.00635249307554], [27.22281756532491, 78.00644221691765], [27.22289643958467, 78.00649492096328], [27.22303010294016, 78.00658800864326], [27.22321335644781, 78.00663962725584], [27.22351481179987, 78.00669442314425], [27.22352365418302, 78.00676859207246], [27.2236309252516, 78.00679482216694], [27.22368663319429, 78.00679242844315], [27.22372056305084, 78.00683225172138], [27.22386854989248, 78.00690626995332], [27.22393157720886, 78.00672508095536], [27.22417673973057, 78.00680949360573], [27.22422407441107, 78.00687302425331], [27.22434160791063, 78.00690731285012], [27.2245935562065, 78.00699969101295], [27.22474560425178, 78.00704658122179], [27.22502355907415, 78.00706183589207], [27.22551672414181, 78.00709844119642], [27.22568326306432, 78.0071184832885], [27.22594186265082, 78.00706317650338], [27.22644926795797, 78.00708460050777], [27.22668617286167, 78.00706762245709], [27.2267846524362, 78.00717922461617], [27.22757529406595, 78.00729387292628], [27.22804312032075, 78.00737649520039], [27.22886149003792, 78.00749578406841], [27.22955198039594, 78.00757661419995], [27.23022689284195, 78.00773485380117], [27.23063879377074, 78.00766810492914], [27.2309635805258, 78.00777023331432], [27.23175539085207, 78.00783044489589], [27.23213035325684, 78.00786387930094], [27.23234038316607, 78.00650753008267], [27.23242495188152, 78.00580934642166], [27.2325220870109, 78.00517376214376], [27.23257004692742, 78.00456020385977], [27.23264548249957, 78.0039629487347], [27.23272291880556, 78.00327235164103], [27.23280975158724, 78.00279214400356], [27.2329216138809, 78.00211803474582], [27.23308798697958, 78.00214585038871], [27.23326519934334, 78.00069519873205], [27.23333177999546, 78.00051019475653], [27.23363009535508, 78.0005493318198], [27.23370167898252, 78.00013097217062], [27.23365005652785, 77.99994279574975], [27.23548298640669, 77.9991436169689], [27.23733917655239, 77.99888208169753], [27.23927668491421, 77.998397004347], [27.24012996270293, 77.9981863888125], [27.2405613876413, 77.99818239345637], [27.24391676007466, 77.99706560813125]]}});

I'm not able to execute above full command in the mongo shell. Also I've tried to use mongo-shell variable in following way...

var file = cat('/home/vivek/locationCoordinates.json');
db.geoPolygonData.insert({"polygonName":"location6", "polygons":{"type":"Polygon", coordinates:[file]}});

But it storing coordinates in a string not an array.

Please let me know, Is there any limitation to execute such large query? or if there is any other way around to execute such commands.


回答1:


cat just reads the file, it doesn't parse the file as json.

Try:

var file = JSON.parse(cat('/home/vivek/locationCoordinates.json'));
db.geoPolygonData.insert({"polygonName":"location6", "polygons":{"type":"Polygon", coordinates:[file]}});



回答2:


There is a limit for a document, but it might not be your case.

The maximum BSON document size is 16 megabytes.

The maximum document size helps ensure that a single document cannot use excessive amount of RAM or, during transmission, excessive amount of bandwidth. To store documents larger than the maximum size, MongoDB provides the GridFS API.

Another point is related to Shell:

The mongo shell prompt has a limit of 4095 codepoints for each line. If you enter a line with more than 4095 codepoints, the shell will truncate it.

MongoDB Limits and Thresholds might be a good option to check.

There are some workarounds of how you can deal with long commands. Here you can also find some good advices.




回答3:


Create a JavaScript file called as insert_large_array_doc.js, with the following contents:

let doc = { "polygonName": "location1",  "polygons": {"type": "Polygon", coordinates: [ [27.24391676007466, 77.99706560813125], [27.24663657232702, 77.99603771498144], ...
..., [27.24391676007466, 77.99706560813125] ] } }

db.collection.insertOne(doc);

From the mongo shell (specify the entire file path of the JS file):

mongo > load("insert_large_array_doc.js");

The document will be inserted into the collection. Query the document:

mongo > db.collection.find()


来源:https://stackoverflow.com/questions/61606646/insert-large-record-into-mongodb-using-mongo-shell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!