【发布时间】:2014-07-04 12:34:30
【问题描述】:
在查询 mongodb 数据库时,是否可以在 $or 语句中执行多个地理查询,例如 $near 或 $geoNear?
我总是收到错误“异常:$ 或可能不包含‘特殊’查询”
经过一番谷歌搜索后,我发现问题https://jira.mongodb.org/browse/SERVER-3984 已关闭并标记为“已修复”。
对我来说,运行多个地理查询时似乎仍然存在错误。 这是我的测试代码:
db.entry.find({
$or: [
{
"address.geo": {
$near: {
$geometry : {
type : "Point" ,
coordinates : [ 9.7043 , 52.3019 ] },
$maxDistance : 50000
}
}
},
{
"address.geo": {
$near: {
$geometry : {
type : "Point" ,
coordinates : [ 9.6043 , 52.1019 ] },
$maxDistance : 50000
}
}
}
]
}).count();
这就是结果:
uncaught exception: count failed: {
"errmsg" : "exception: $or may not contain 'special' query",
"code" : 13291,
"ok" : 0
}
【问题讨论】:
-
你用的是什么版本的mongodb?
-
由于我们仍处于评估阶段,我们处于最新版本 - 2.6.3
标签: mongodb