F
F
Friend2016-11-01 19:11:12
MongoDB
Friend, 2016-11-01 19:11:12

How to fix error with $_id_ when loading json in mongodb?

I start to load json into mongodb using the command mongoimport --db test --collection one1 --file my.json and the error
2016-11-01T17:57:23.003+0200 flies insertDocument :: caused by :: 11000 E11000 duplicate key error index : test .one1.$_id_ dup key: { : "01001" }
json example

{ "_id" : "01001", "city" : "AGAWAM", "loc" : [ -72.622739, 42.070206 ], "pop" : 15338, "state" : "MA" }
{ "_id" : "01002", "city" : "CUSHMAN", "loc" : [ -72.51564999999999, 42.377017 ], "pop" : 36963, "state" : "MA" }
etc.
json is not an option

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dimonchik, 2016-11-01
@dimonchik2013

stackoverflow.com/questions/17114851/mongo-id-fiel...
there is something about demolishing indexes
but in general, if this occurs, problems are waiting for you somewhere

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question