![](/img/trans.png)
[英]Full Text Search in MongoDB not yielding the expected result for "@@@"
[英]MongoDB query for full text search and Geo returning wrong result
當我們嘗試搜索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
根據2.4文檔 ,文本索引不適用於$ near:
注意不能將需要特殊文本索引的text命令與需要不同類型特殊索引的查詢運算符組合在一起。 例如,您不能將文本與$ near運算符組合在一起。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.