2015-10-04 76 views
0

我遇到了一個問題,需要在某個來源找到用戶並根據其目標位置對其進行聚合。我試圖用接近查詢多個$以下所列:

db.getCollection('user_requests').find({"destGeoLoc":$near:{$geometry: {$type:"Point", coordinates:77.2432720999999987,28.5676954999999992]},$maxDistance:2000}},"sourceGeoLoc":{$near:$geometry: {$type:"Point",coordinates:77.2219549999999941,28.6423729999999992]},$maxDistance:2000}}, "match_status" : "no" }) 

它給了以下錯誤:

error: { 
"$err" : "Can't canonicalize query: BadValue Too many geoNear expressions", 
"code" : 17287 

}

現在我明白了錯誤本身,但我似乎遇到了關於如何克服這個錯誤的障礙。

回答

0

我想通過在源和目標上發佈兩個單獨的$ near查詢並獲取ObjectId的集合交集來找到解決方案。這很粗糙,但工作。