![](/img/trans.png)
[英]Mongoose near(…) query on 2dsphere indexed field not returning valid results
[英]Mongoose query with $near $or other field
我試圖通過在不同的字段上執行查詢$或包括有問題的$ near查詢來返回文檔。
架構
locationSchema{
...
beacon: String,
access_point: String,
gps: [],
...
}
locationSchema.index({ gps: '2dsphere' });
詢問
locations.find({
'$or': [
{
gps: {
'$near': {
'$geometry': {
type: 'Point',
coordinates: [
13.1313131,
-4.444444
]
},
'$maxDistance': 50,
distanceField: 'distance',
spherical: true
}
}
},
{
access_point: '88:A6:BB:26:95:11'
},
{
access_point: '88:A6:C6:26:CC:21'
}
]
},
function(err,locations){
//DosomethingwithfoundLocations
});
如果僅使用$near
輸入執行查詢,則將按預期返回一個位置;如果僅使用access_point
的列表進行查詢, access_point
返回一個位置,但兩個查詢都在同一位置運行時,則不會返回時間。
我假設這是一個錯誤,但是無論如何,我可以使這種查詢工作嗎?
謝謝
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.