Aktualizujte své dokumenty a vytvořte novou kolekci
db.location.aggregate([
{ "$addFields": {
"location": {
"type": "Point",
"coordinates": ["$location.loc.lng", "$location.loc.lat"]
},
"geocode": "$location.geocode"
}},
{ "$out": "location" }
])
Poté vytvořte index na location
pole
db.location.createIndex({ "location": "2d" })