当我们尝试通过 mongo cli 搜索时,我们没有得到正确的数据。这是完整的场景:
我们在一个集合中有以下 JSON:
"_id" : 18348,
"Name" : "Applebee's Neighborhood Grill",
"AddressLine1" : "2545 Scottsville Rd, Bowling Green, KY - 42104, United States",
"loc" : {
"lng" : -86.42583465576172,
"lat" : 36.95203399658203
},
"ProfilePicturePath" : "",
"MarketID" : 92,
"TotalFavorites" : 0,
"PriceRating" : null,
"ProfileType" : "R",
"Cuisines" : [ ],
"Rating" : 4
当我们搜索同时提供地理查询和全文的位置时,我们得到的结果不正确。在这种情况下(如下)我改变了经度: db.rests.runCommand( "text", {search:"Applebee's", filter:{ loc : { $near : [-86.43113708496094,136.963356018066406] , $maxDistance : 1/69 }} })
我得到:
{
"queryDebugString" : "applebe||||||",
"language" : "english",
"results" : [
{
"score" : 0.6666666666666666,
"obj" : {
"_id" : 18348,
"Name" : "Applebee's Neighborhood Grill",
"AddressLine1" : "2545 Scottsville Rd, Bowling Green, KY - 42104, United States",
"loc" : {
"lng" : -86.42583465576172,
"lat" : 36.95203399658203
},
"ProfilePicturePath" : "",
"MarketID" : 92,
"TotalFavorites" : 0,
"PriceRating" : null,
"ProfileType" : "R",
"Cuisines" : [ ],
"Rating" : 4
}
}
],
"stats" : {
"nscanned" : 1,
"nscannedObjects" : 1,
"n" : 1,
"nfound" : 1,
"timeMicros" : 92
},
"ok" : 1
}
我们尝试了以下索引:
db.rests.ensureIndex( { "locs": "2d" } )
db.rests.ensureIndex({Name: "text",AddressLine1: "text"})
db.rests.ensureIndex({Name: "text",AddressLine1: "text"},{"loc":"2d"})
也许我们做错了什么?如果我们不使用地理过滤器并使用评级等其他过滤器,它的工作正常。
请帮助
阿米特
http://www.aquevix.com