使用MongoDB接口的Azure CosmosDB地理空间查询行为异常
我在Azure Cosmosdb(MongoDB API)中有一个集合,其中有一组包含地理空间数据的文档。当我在数据库中查询特定多边形中的所有点时,使用MongoDB shell会正确地返回这些点,但使用pymongo不会给出任何结果。更具体地说: 在mongodb shell中使用MongoDB接口的Azure CosmosDB地理空间查询行为异常,mongodb,azure,azure-cosmosdb,geospatial,Mongodb,Azure,Azure Cosmosdb,Geospatial,我在Azure Cosmosdb(MongoDB API)中有一个集合,其中有一组包含地理空间数据的文档。当我在数据库中查询特定多边形中的所有点时,使用MongoDB shell会正确地返回这些点,但使用pymongo不会给出任何结果。更具体地说: 在mongodb shell中 globaldb:PRIMARY> db.test_collection.find( { "Location" : { "$geoWithin" : { "$geometry" : { "type" : "Po
globaldb:PRIMARY> db.test_collection.find( { "Location" : { "$geoWithin" : { "$geometry" : { "type" : "Polygon" ,"coordinates" :[ [ [ 0 , 0 ] , [ 41 , 0 ] , [41,6],[0,6], [0,0] ] ] } } } } )
{ "_id" : ObjectId("5e395a9929ae6f6ec66bc97e"), "info" : "test_info", "region" : "region", "Location" : { "type" : "Point", "coordinates" : [ 40, 5 ] } }
{ "_id" : ObjectId("5e395ab895c1327b1c4568b4"), "info" : "test_info", "region" : "region", "Location" : { "type" : "Point", "coordinates" : [ 40, 5 ] } }
{ "_id" : ObjectId("5e395b6bd76420859e134e26"), "info" : "test_info", "region" : "region", "Location" : { "type" : "Point", "coordinates" : [ 40, 5 ] } }
记录已正确返回
python语言(pymongo)
什么也没给我
我做错了什么
cur_collection = db.test_collection
points_in = cur_collection.find(
{ "Location" :
{ "$geoWithin" :
{ "$geometry" : { "type" : "Polygon",
"coordinates" :
[ [
[ 0 , 0 ] ,
[ 41 ,0 ] ,
[ 41 ,6 ],
[ 0, 6],
[ 0, 0]
] ]
}
}
}
}
)
for point in points_in:
print(point)