Mongodb – The featureCompatibilityVersion must be 3.4 to use collation

geospatialmongodb

I need to integrate miles/distance search in my website and I am using MongoDB geospatial indexes, however, I am getting some and unable to resolve. below are my schema and command I am using…

=> 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
            ]
        }
    }
}

Below is my indexes…

=> 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"
    }
]

However, when I run following command in mongo shell, I am getting an error…

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

error:

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

There is the link (http://dochub.mongodb.org/core/3.4-feature-compatibility) in the error message and I follow that link, it suggests to set the setFeatureCompatibilityVersion to "3.4"., I run that command and again getting some other error

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

Please help me solve this error.

Best Answer

Need db.adminCommand( { setFeatureCompatibilityVersion: "3.4" } )

Related Topic