mongodb - mongo 索引問題 geo
大家讲道理
大家讲道理 2017-05-02 09:20:31
0
1
718
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

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

全部回覆(1)
黄舟

{2dsphereIndexVersion: 3}是MongoDB 3.2开始支持的新版本,3.2默认使用这个版本创建2dsphere索引。如果你建立索引時使用的不是這個版本,只能說明你使用的版本不是3.2。請先檢查這一點。
另外原則上講不應該把新版本的資料庫恢復到舊版本上(雖然不一定會造成問題),所以你本地使用的mongodb版本應該至少比線上要新。
關於version 3和version 2的區別有興趣可以看看這篇blog。

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!