db.tablebusiness.find({ "LongitudeLatitude" : { "$nearSphere" : [106.772835, -6.186753], "$maxDistance" : 0.053980478460939611 }, "Prominent" : { "$gte" : 15 }, "indexContents" : { "$all" : [/^soto/, /^nasi/] } }).limit(200);
db.tablebusiness.find({ "LongitudeLatitude" : { "$nearSphere" : [106.772835, -6.186753], "$maxDistance" : 0.053980478460939611 }, "Prominent" : { "$gte" : 15 }, "indexContents" : { "$in" : [/^soto/, /^nasi/] } }).limit(200);
这是结果
/* 88 */
{
"ts" : ISODate("2012-09-11T06:57:26.801Z"),
"op" : "query",
"ns" : "newisikota.tablebusiness",
"query" : {
"LongitudeLatitude" : {
"$nearSphere" : [106.772835, -6.186753],
"$maxDistance" : 0.053980478460939611
},
"Prominent" : {
"$gte" : 15.0
},
"indexContents" : {
"$all" : [/^soto/, /^nasi/]
}
},
"ntoreturn" : 200,
"nscanned" : 48,
"nreturned" : 48,
"responseLength" : 60002,
"millis" : 3821,
"client" : "127.0.0.1",
"user" : ""
}
/* 89 */
{
"ts" : ISODate("2012-09-11T06:57:43.147Z"),
"op" : "query",
"ns" : "newisikota.tablebusiness",
"query" : {
"LongitudeLatitude" : {
"$nearSphere" : [106.772835, -6.186753],
"$maxDistance" : 0.053980478460939611
},
"Prominent" : {
"$gte" : 15.0
},
"indexContents" : {
"$in" : [/^soto/, /^nasi/]
}
},
"ntoreturn" : 200,
"nscanned" : 200,
"nreturned" : 200,
"responseLength" : 249598,
"millis" : 320,
"client" : "127.0.0.1",
"user" : ""
}
注意:$all 查询可以偶尔运行 26 秒。
解释结果如下:
db.tablebusiness.find({ "LongitudeLatitude" : { "$nearSphere" : [106.772835, -6.186753], "$maxDistance" : 0.053980478460939611 }, "Prominent" : { "$gte" : 15 }, "indexContents" : { "$all" : [/^soto/, /^nasi/] } }).limit(200).explain();
{
"cursor" : "GeoSearchCursor",
"nscanned" : 48,
**"nscannedObjects" : 48,**
"n" : 48,
"millis" : 8563,
"nYields" : 0,
"nChunkSkips" : 0,
"isMultiKey" : false,
"indexOnly" : false,
"indexBounds" : {
}
}
>
db.tablebusiness.find({ "LongitudeLatitude" : { "$nearSphere" : [106.772835, -6.186753], "$maxDistance" : 0.053980478460939611 }, "Prominent" : { "$gte" : 15 }, "indexContents" : { "$in" : [/^soto/, /^nasi/] } }).limit(200).explain();
{
"cursor" : "GeoSearchCursor",
"nscanned" : 200,
**"nscannedObjects" : 200,**
"n" : 200,
"millis" : 516,
"nYields" : 0,
"nChunkSkips" : 0,
"isMultiKey" : false,
"indexOnly" : false,
"indexBounds" : {
}
}
请注意,$in 搜索会扫描更多对象。
最坏的情况是最坏的情况,mongdob 可以进行 $in 搜索,然后过滤掉。比例应该不会很大。