我有一个如下所示的数据结构。如何为该结构定义地理索引?
{
"currentGeoLocation": {
"latitude": -10,
"longitude": 1
}
}
我试过这些命令:1-
db.test.ensureIndex({ type: "geo", fields: [ "currentGeoLocation[latitude]","currentGeoLocation[longitude]" ] });
2-
db.test.ensureIndex({ type: "geo", fields: [ "currentGeoLocation.latitude","currentGeoLocation.longitude" ] });
但我认为没有一个能正常工作。因为在我搜索最近的项目后,我得到了 []。有什么问题?