当前位置:  开发笔记 > 编程语言 > 正文

featureCompatibilityVersion必须为3.4才能使用排序规则

如何解决《featureCompatibilityVersion必须为3.4才能使用排序规则》经验,为你挑选了1个好方法。

我需要在我的网站中集成里程/距离搜索,我正在使用MongoDB地理空间索引,但是,我得到一些并且无法解决.下面是我正在使用的架构和命令......

=> db.properties.findOne({},{address:1})
{
    "_id" : ObjectId("585b909c870d907845b695fd"),
    "address" : {
        "postcode" : "W1D 1NN",
        "address1" : "Essence",
        "address2" : "United Kingdom House",
        "county" : "London",
        "town" : "LONDON",
        "latitude" : "51.5160229933117",
        "longitude" : "-0.139088472429092",
        "house_number" : "114",
        "location" : {
            "type" : "Point",
            "coordinates" : [
                -0.139088472429092,
                51.5160229933117
            ]
        }
    }
}

以下是我的索引......

=> db.properties.getIndexes()
[
    {
        "v" : 1,
        "key" : {
            "_id" : 1
        },
        "name" : "_id_",
        "ns" : "cherrydoorsync.properties"
    },
    {
        "v" : 1,
        "key" : {
            "address.location.coordinates" : "2d"
        },
        "name" : "address.location.coordinates_2d",
        "ns" : "cherrydoorsync.properties"
    }
]

但是,当我在mongo shell中运行以下命令时,我收到错误...

db.properties.aggregate([
   {
     $geoNear: {
        near: { type: "Point", coordinates: [  -2.94379156655216, 54.8905641133194 ] },
        distanceField: "dist.calculated",
        maxDistance: 2,
        includeLocs: "dist.location",
        num: 5
     }
   }
])

错误:

assert:命令失败:{"ok":0,"errmsg":"geoNear命令失败:{ok:0.0,errmsg:\"featureCompatibilityVersion必须为3.4才能使用排序规则.请参阅 http ://dochub.mongodb.org/core/3.4-feature-compatibility.\",代码:72,codeName:\"InvalidOptions \"}","code":16604,"codeName":"Location16604"} :聚合失败_getErrorWithCode@src/mongo/shell/utils.js:25:13 doassert@src/mongo/shell/assert.js:16:14 assert.commandWorked@src/mongo/shell/assert.js:370:5 DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1319:5 @(shell):1:1

2017-01-20T13:41:27.914+0530 E QUERY    [main] Error: command failed:     {
    "ok" : 0,
    "errmsg" : "geoNear command failed: { ok: 0.0, errmsg: \"The featureCompatibilityVersion must be 3.4 to use collation. See

http ://dochub.mongodb.org/core/3.4-feature-compatibility.\",代码:72,codeName:\"InvalidOptions \"}","code":16604,"codeName":"Location16604"}:聚合失败:_getErrorWithCode@src/mongo/shell/utils.js:25:13 doassert@src/mongo/shell/assert.js:16:14 assert.commandWorked@src/mongo/shell/assert.js:370:5 DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1319:5 @(shell):1:1

在错误消息中有链接(http://dochub.mongodb.org/core/3.4-feature-compatibility),我按照该链接,它建议设置 setFeatureCompatibilityVersion to "3.4".,我运行该命令,并再次得到一些其他错误

> db.adminCommand( { setFeatureCompatibilityVersion: <"3.4" } )
2017-01-20T13:45:39.023+0530 E QUERY    [main] SyntaxError: expected expression, got '<' @(shell):1:51

请帮我解决这个错误.



1> 小智..:

需要 db.adminCommand( { setFeatureCompatibilityVersion: "3.4" } )

推荐阅读
黄晓敏3023
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有