2016-08-30 28 views
1

私はMongoDB/Mongooseを初めて使用しています。私は、herokuのDBを作成するためにlocaldbをダンプする過程にあります。重複インデックスのMongodbエラー

2016-08-29T22:05:00.411-0500 building a list of collections to restore from /Users/micahsherman/tmp/mongodump/Loc8r dir 
2016-08-29T22:05:00.518-0500 reading metadata for heroku_n1kxxxxxx.locations from /Users/micahsherman/tmp/mongodump/Loc8r/locations.metadata.json 
2016-08-29T22:05:00.518-0500 reading metadata for heroku_n1kxxxxxx.test from /Users/micahsherman/tmp/mongodump/Loc8r/test.metadata.json 
2016-08-29T22:05:00.519-0500 restoring heroku_n1kxxxxxx.test from /Users/micahsherman/tmp/mongodump/Loc8r/test.bson 
2016-08-29T22:05:00.519-0500 restoring heroku_n1kxxxxxx.locations from /Users/micahsherman/tmp/mongodump/Loc8r/locations.bson 
2016-08-29T22:05:00.520-0500 restoring indexes for collection heroku_n1kxxxxxx.test from metadata 
2016-08-29T22:05:00.574-0500 finished restoring heroku_n1kxxxxxx.test (0 documents) 
2016-08-29T22:05:00.799-0500 error: multiple errors in bulk operation: 
    - E11000 duplicate key error index: heroku_n1kxxxxxx.locations.$_id_ dup key: { : ObjectId('57c334af05803d85c7b9e780') } 
    - E11000 duplicate key error index: heroku_n1kxxxxxx.locations.$_id_ dup key: { : ObjectId('57c3819605803d85c7b9e783') } 

2016-08-29T22:05:00.799-0500 restoring indexes for collection heroku_n1kxxxxxx.locations from metadata 
2016-08-29T22:05:00.852-0500 finished restoring heroku_n1kxxxxxx.locations (2 documents) 
2016-08-29T22:05:00.852-0500 done 

これらは、Herokuのからの接続を防ぐ:私はmongorestoreを実行すると、私は次のエラー(複数可)を取得します。私はここに、コンソールに入っおよびインデックスを印刷した

結果は以下のとおりです。

rs-ds017886:PRIMARY> db.system.indexes.find(); 
{ "v" : 1, "key" : { "_id" : 1 }, "name" : "_id_", "ns" : "heroku_n1kxxxxxx.test" } 
{ "v" : 1, "key" : { "_id" : 1 }, "name" : "_id_", "ns" : "heroku_n1kxxxxxx.locations" } 
{ "v" : 1, "key" : { "coords" : "2dsphere" }, "name" : "coords_2dsphere", "ns" : "heroku_n1kxxxxxx.locations", "background" : true, "2dsphereIndexVersion" : 2 } 
{ "v" : 1, "key" : { "_id" : 1 }, "name" : "_id_", "ns" : "heroku_n1kxxxxxx.objectlabs-system" } 
{ "v" : 1, "key" : { "_id" : 1 }, "name" : "_id_", "ns" : "heroku_n1kxxxxxx.objectlabs-system.admin.collections" } 
rs-ds017886:PRIMARY> 

は、私はこれをデバッグについて移動する方法が非常にわかりません。思考?

答えて

0

locations.bsonファイルが重複していないことを確認してください('57c334af05803d85c7b9e780' & '57c3819605803d85c7b9e783')。インデックスを作成する前にデータを追加しているようです。ここで

は私が(データを見ずに言うのは難しい)起きてと信じるものの一例です

> db.people.insert({name: "Matt"}) 

WriteResult({ "nInserted" : 1 }) 

> db.people.insert({name: "Matt"}) 

WriteResult({ "nInserted" : 1 }) 

> db.people.createIndex({name: 1}, {unique: true}) 

{ 
    "ok" : 0, 
    "errmsg" : "E11000 duplicate key error index: test.people.$name_1 dup key: { : \"Matt\" }", 
    "code" : 11000 
} 

_idフィールドには、すでに独自の制約が含まれています

関連する問題