I have an Azure CosmosDB with a collection restaurants
where a field geoJSON
specifies the location of a restaurant in geoJSON format. I am using the MongoDB API to access this.
When I log into the DB using the mongo shell, I am able to see all the documents using db.restaurants.find()
. I created a 2dsphere geospatial index using db.restaurants.createIndex( {geoJSON: "2dsphere"})
.
output:
{
"_t" : "CreateIndexesResponse",
"ok" : 1,
"createdCollectionAutomatically" : false,
"numIndexesBefore" : 3,
"numIndexesAfter" : 4
}
However, upon running db.restaurants.getIndexes()
, I still see only three indexes. This question says that indexing is not allowed. Is this still the case?
Furthermore, there seems to be an index called
{
"v" : 1,
"key" : {
"DocumentDBDefaultIndex" : "2dsphere"
},
"name" : "DocumentDBDefaultIndex_2dsphere",
"ns" : "<redacted>"
}
,but executing a geospatial query returns nothing.
db.restautants.find({DocumentDBDefaultIndex: {$near: {$geometry: {type: "Point", coordinates: [24.9430111, 60.166608]}, $maxDistance: 1000}}})
How can I execute geospatial queries against this index using the mongo shell? Is this a bug in CosmosDB?