2012-09-07 45 views
1

我运行此查询在蒙戈外壳,并成功获取结果为什么使用GeohayStack失败

db.tablebusiness.find({ "LongitudeLatitude" : { "$near" : [106.772835, -6.186753], "$maxDistance" : 0.053980478460939611 }, "indexContents" : { "$all" : [/^warung/] } }).limit(2); 

我:

{ 
    "_id" : "warung-nasi-nur-karomah__-6.19_106.78", 
    "BuildingID" : null, 
    "Title" : "Warung Nasi Nur Karomah", 
    "InBuildingAddress" : null, 
    "Building" : null, 
    "Street" : "Jl. Arjuna Utara No.35", 
    "Districts" : [], 
    "City" : "Jakarta", 
    "Country" : "Indonesia", 
    "LongitudeLatitudeFromGoogle" : null, 
    "DistanceFromGoogleAddress" : 0.0, 
    "Checkin" : 0, 
    "Note" : null, 
    "PeopleCount" : 0, 
    "Prominent" : 45.5, 
    "CountViews" : 0, 
    "StreetAdditional" : null, 
    "LongitudeLatitude" : { 
    "Longitude" : 106.775693893433, 
    "Latitude" : -6.18759540055471 
    }, 
    "Rating" : { 
    "Stars" : 0.0, 
    "Weight" : 0.0 
    }, 
    "Reviews" : [], 
    "ZIP" : null, 
    "Tags" : ["Restaurant"], 
    "Phones" : ["081380087011"], 
    "Website" : null, 
    "Email" : null, 
    "Price" : null, 
    "openingHour" : null, 
    "Promotions" : [], 
    "SomethingWrong" : false, 
    "BizMenus" : [], 
    "Brochures" : [], 
    "Aliases" : [], 
    "indexContents" : ["restaura", "estauran", "staurant", "taurant", "aurant", "urant", "rant", "ant", "nt", "t", "warung", "arung", "rung", "ung", "ng", "g", "nasi", "asi", "si", "i", "nur", "ur", "r", "karomah", "aromah", "romah", "omah", "mah", "ah", "h"] 
} 

但当我尝试此查询与其他搜索多键索引我没有什么结果

db.runCommand({ geoSearch : "tablebusiness", near : [106.772835, -6.186753], maxDistance : 0.053980478460939611, search : { "indexContents" : { "$all" : [/^warung/] } }, limit : 30 }) 

我得到这个

{ 
     "results" : [ ], 
     "stats" : { 
       "time" : 0, 
       "btreeMatches" : 0, 
       "n" : 0 
     }, 
     "ok" : 1 
} 

这是指数在我收集数据库

[ 
     { 
       "v" : 1, 
       "key" : { 
         "_id" : 1 
       }, 
       "ns" : "isikotacobacoba.tablebusiness", 
       "name" : "_id_" 
     }, 
     { 
       "v" : 1, 
       "key" : { 
         "LongitudeLatitude" : "2d", 
         "Prominent" : -1, 
         "indexContents" : 1 
       }, 
       "ns" : "isikotacobacoba.tablebusiness", 
       "name" : "LongLat_Prominent_indexContents", 
       "dropDups" : false, 
       "background" : false 
     }, 
     { 
       "v" : 1, 
       "key" : { 
         "LongitudeLatitude" : "2d", 
         "Prominent" : -1 
       }, 
       "ns" : "isikotacobacoba.tablebusiness", 
       "name" : "LongLat_Prominent", 
       "dropDups" : false, 
       "background" : false 
     }, 
     { 
       "v" : 1, 
       "key" : { 
         "indexContents" : 1 
       }, 
       "ns" : "isikotacobacoba.tablebusiness", 
       "name" : "indexContents", 
       "dropDups" : false, 
       "background" : false 
     }, 
     { 
       "v" : 1, 
       "key" : { 
         "LongitudeLatitude" : "2d", 
         "indexContents" : 1, 
         "Prominent" : -1 
       }, 
       "ns" : "isikotacobacoba.tablebusiness", 
       "name" : "LongitudeLatitude__indexContents_1_Prominent_-1", 
       "bits" : 22 
     }, 
     { 
       "v" : 1, 
       "key" : { 
         "Title" : 1 
       }, 
       "ns" : "isikotacobacoba.tablebusiness", 
       "name" : "Title", 
       "dropDups" : false, 
       "background" : false 
     }, 
     { 
       "v" : 1, 
       "key" : { 
         "City" : 1 
       }, 
       "ns" : "isikotacobacoba.tablebusiness", 
       "name" : "City", 
       "dropDups" : false, 
       "background" : false 
     }, 
     { 
       "v" : 1, 
       "key" : { 
         "LongitudeLatitude" : "geoHaystack", 
         "indexContents" : 1 
       }, 
       "ns" : "isikotacobacoba.tablebusiness", 
       "name" : "LongitudeLatitude__indexContents_1", 
       "bucketSize" : 0.1 
     } 
] 

格式中使用RunCommand MongoDB的使用如何与geohaystack附加字段mulikey?

回答

1

Geohaystack查询不支持阵列的附加字段, 只有单个值。当前实施的地理空间索引 和geohaystacks不使用标准查询和索引代码。

从MongoDB的geohaystack文档中的示例( http://www.mongodb.org/display/DOCS/Geospatial+Haystack+Indexing) 仅示出了附加的字段是一个简单的单个值,而不是在geohaystack查询一个 数组值。