Error Query Operators

Hi people!
I'm having problems executing queries in MongoDB inside Metabase with geospatial query operator. Could you help me?

[$match: {
location: {
$near: {
$geometry: { type: "Point", coordinates: [ -40.28, -20.312 ] },
$minDistance: 1000,
$maxDistance: 5000
}
}
}
]

The error:
Command failed with error 2 (BadValue): '$geoNear, $near, and $nearSphere are not allowed in this context' on server mongo-qa-common-shard-00-02.lfnyi.mongodb.net:27017. The full response is { "operationTime" : { "$timestamp" : { "t" : 1633122473, "i" : 1 } }, "ok" : 0.0, "errmsg" : "$geoNear, $near, and $nearSphere are not allowed in this context", "code" : 2, "codeName" : "BadValue", "$clusterTime" : { "clusterTime" : { "$timestamp" : { "t" : 1633122473, "i" : 1 } }, "signature" : { "hash" : { "$binary" : "ngMRSKK2AoMILyT9B4eQuMPyKz8=", "$type" : "00" }, "keyId" : { "$numberLong" : "6984105916991799297" } } } }

Hi @Paolastekl
Metabase currently does not support geospatial data type, but there's a request for it and possible workaround:
https://github.com/metabase/metabase/issues/1331 - upvote by clicking :+1: on the first post

But the error that is returned from the MongoDB seems to indicate that you need to modify it slightly:
https://stackoverflow.com/questions/53133198/geonear-near-and-nearsphere-are-not-allowed-in-this-context

1 Like