我这里有一个基于几何的查询,它被嵌套在$or内,并与 $and 操作符结合使用。Mongo一直抛出以下错误:
MongoError: Can't canonicalize query: BadValue geoNear must be top-level expr
我正在使用原生的Mongo Node驱动程序版本1.4.3。我看到这里发布了一个类似的bug。
这是我构建查询的问题,还是应该向Mongo报告bug?
{
"$or": [
{
"$and": [
{
"startDate": {
"$gt": "2013-12-27T08:00:00.000Z"
}
},
{
"startDate": {
"$lt": "2013-02-08T08:00:00.000Z"
}
},
{
"loc": {
"$near": {
"$geometry": {
"type": "Point",
"coordinates": [
123.3423,
22.2131
]
},
"$maxDistance": 4
}
}
}
]
},
{
"$and": [
{
"startDate": {
"$gt": "2013-12-27T08:00:00.000Z"
}
},
{
"startDate": {
"$lt": "2013-02-08T08:00:00.000Z"
}
}
]
}
]
}