Failed: psg.cabinet: error creating indexes for psg.cabinet: createIndex error: exception: unsupported geo index version { 2dsphereIndexVersion : 2dsphereIndexVersion: 3 }, only support versions: [1,2]
这是我同步线上的mongo数据报错的, 线上用的3.2.4 ,我观察发现这个集合的索引是
{
"v" : 1,
"key" : {
"location.loc" : "2dsphere"
},
"name" : "location.loc_2dsphere",
"ns" : "psg.cabinet",
"2dsphereIndexVersion" : 3
}
然后我同步到本地的时候就报上面的错,我的Mongo版本是 3.2.0,但加索引后是
{
"v" : 1,
"key" : {
"location.loc" : "2dsphere"
},
"name" : "location.loc_2dsphere",
"ns" : "psg.cabinet",
"2dsphereIndexVersion" : 2
}
请问下 这里的 2dsphereIndexVersion 怎么去改为3
{2dsphereIndexVersion: 3}
是MongoDB 3.2开始支持的新版本,3.2默认使用这个版本创建2dsphere
Index. If you are not using this version when creating the index, it only means that the version you are using is not 3.2. Please check this first.In addition, in principle, the new version of the database should not be restored to the old version (although it may not cause problems), so the mongodb version you use locally should be at least newer than the online one.
If you are interested in the difference between version 3 and version 2, you can read this blog.