I have CosmosDB MongoDB-API instance.
Mongo server version = 4.0.0
Inserted documents look like:
{
"_id": "111",
"fileName": "some.txt",
"type": "ONE",
"location": {
"type": "MultiPoint",
"coordinates": [
[4, 4]
]
},
"aPoint": {
"type": "Point",
"coordinates": [4, 4]
}
}
I created geo spatial indexes with mongosh(also I've tried with MongoDB Compass):
db.coll.createIndex({ location: "2dsphere" })
db.coll.createIndex({ aPoint: "2dsphere" })
result of db.coll.getIndexes()
[
{
v: 1,
key: { _id: 1 },
name: '_id_',
ns: 'ns_name.coll'
},
{
v: 1,
key: { location: '2dsphere' },
name: 'location_2dsphere',
ns: 'ns_name.coll'
},
{
v: 1,
key: { aPoint: '2dsphere' },
name: 'aPoint_2dsphere',
ns: 'ns_name.coll'
}
]
I have tried a lot of queries:
db.coll.find( { "aPoint": { $nearSphere : [ 4, 4 ], $maxDistance: 1000 } } )
db.coll.find( { "aPoint.coordinates": { $nearSphere : [ 4, 4 ], $maxDistance: 1000 } } )
db.coll.find({aPoint : { $nearSphere:{ $geometry: { type: "Point", coordinates: [4, 4] }, $maxDistance: 1000 }}} )
db.coll.find({"aPoint.coordinates": { $nearSphere:{$geometry:{ type: "Point", coordinates: [4, 4]}, $maxDistance: 1000 }}})
db.coll.find({ "location": { $nearSphere : [ 4, 4 ], $maxDistance: 1000 }})
db.coll.find({ "location.coordinates": { $nearSphere : [ 4, 4 ], $maxDistance: 1000 }})
db.coll.find({location: { $nearSphere:{ $geometry: { type: "Point", coordinates: [4, 4] }, $maxDistance: 1000 }}} )
db.coll.find({"location.coordinates":{$nearSphere:{ $geometry:{ type:"Point",coordinates:[4, 4]}, $maxDistance:1000 }}})
But none of them works. The result is empty.
Do you know how I can make it work for Azure CosmosDB?
Thank you in advance.