我在 mongo shell 中运行此查询,并成功获取结果
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
}
]
如何使用带有附加字段 mulikey 的 geohaystack 使用 runCommand mongoDB 格式?