gpt4 book ai didi

mongodb - featureCompatibilityVersion 必须是 3.4 才能使用排序规则

转载 作者:IT老高 更新时间:2023-10-28 13:10:56 27 4
gpt4 key购买 nike

我需要在我的网站中集成英里/距离搜索,并且我正在使用 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: 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.\", code: 72, codeName: \"InvalidOptions\" }", "code" : 16604, "codeName" : "Location16604" } : aggregate failed _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.\", code: 72, codeName: \"InvalidOptions\" }", "code" : 16604, "codeName" : "Location16604" } : aggregate failed : _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 设置为“3.4”。,我运行该命令并再次获取其他命令错误

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

请帮我解决这个错误。

最佳答案

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

关于mongodb - featureCompatibilityVersion 必须是 3.4 才能使用排序规则,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41758970/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com