1
我有一個MongoDB的集合與下列文件中它的命令搜索所有具有place
接近[0,0]
且還有remaining > 0
以及匹配的地點的coords
的文檔。過濾的MongoDB geoNear與查詢
然而,運行命令
db.runCommand(
{
'geoNear':"mycollection",
near:[0,0],
query:{'places.remaining': {'$gt': 0}},
includeLocs: true
}
)
返回:
{
"ns" : "test.mycollection",
"near" : "1100000000000000000000000000000000000000000000000000",
"results" : [
{
"dis" : 0,
"loc" : {
"0" : 0,
"1" : 0
},
"obj" : {
"_id" : ObjectId("4eb479a61258ec97acd1034d"),
"places" : [
{
"coords" : [
1,
0
],
"remaining" : 1
},
{
"coords" : [
0,
0
],
"remaining" : 0
}
]
}
},
{
"dis" : 1,
"loc" : {
"0" : 1,
"1" : 0
},
"obj" : {
"_id" : ObjectId("4eb479a61258ec97acd1034d"),
"places" : [
{
"coords" : [
1,
0
],
"remaining" : 1
},
{
"coords" : [
0,
0
],
"remaining" : 0
}
]
}
}
],
"stats" : {
"time" : 0,
"btreelocs" : 0,
"nscanned" : 2,
"objectsLoaded" : 1,
"avgDistance" : 0.5,
"maxDistance" : 1.0000124312194423
},
"ok" : 1
}
即這兩個地方,即使place
與coords
[0,0]
有remaining = 0
。
我懷疑的是,該查詢是沒有任何影響,但是當我運行
db.runCommand(
{
'geoNear':"mycollection",
near:[0,0],
includeLocs: true,
query:{'foo':'bar'}
}
)
沒有地方返回:
{
"ns" : "test.mycollection",
"near" : "1100000000000000000000000000000000000000000000000000",
"results" : [ ],
"stats" : {
"time" : 0,
"btreelocs" : 0,
"nscanned" : 2,
"objectsLoaded" : 1,
"avgDistance" : NaN,
"maxDistance" : 0
},
"ok" : 1
}
沒有人有任何想法是怎麼回事?我想甚至可以用geoNear
?提前致謝。