azure-cosmosdb - 参数化查询 - 可以使用 GeoJson 对象值吗?
问题描述
考虑以下:
给定以下文档结构:
// Document using Microsoft.Azure.Cosmos.Spatial.Point ...
public class test_doc
{
public String id { get; set; }
public Microsoft.Azure.Cosmos.Spatial.Point geopoint { get; set; }
// More properties
public String desc { get; set; }
}
构建不带参数的查询...
bounds_str = "{'type':'Polygon','coordinates':[[[-113.247049,53.657421],[-113.733431,53.657421],[-113.733431,53.393183],[-113.247049,53.393183],[-113.247049,53.657421]]]}";
sql_query_text = "SELECT * FROM testcontainer t WHERE ST_WITHIN( t.geopoint, " + bounds_str + ")";
query_def = new Microsoft.Azure.Cosmos.QueryDefinition( sql_query_text );
执行上述查询时,查询按预期工作:
Query Total time: 00:00:00.0067482
Total Request Units consumed: 6.73
Documents found: 2
现在使用参数构建 SAME 查询...
sql_query_text = "SELECT * FROM testcontainer t WHERE ST_WITHIN( t.geopoint, @bounds )";
query_def = new Microsoft.Azure.Cosmos.QueryDefinition( sql_query_text );
query_def.WithParameter( "@bounds", bounds_str );
执行上述查询时,我们会得到不同的(不正确的)结果...
Query Total time: 00:00:00.0054688
Total Request Units consumed: 3.1
Documents found: 0
解决方案
推荐阅读
- java - 从一个系统执行 jar 文件时通信链接失败
- javascript - 单击按钮下载 Excel (phpExcel)
- alexa - Alexa 记录用户的话语
- json - 映射 json 数据/对象颤动
- c - 为什么不允许我使用结构的成员?
- python - 如何在数据框上应用肘法
- mysql - mysql-match-is-not-giving-proper-result-when-searching-a-word-with-single-quote
- .net - 对需要 Docker 的 .NET Core 应用程序进行单元测试
- python - 寻求有关移动设备近实时对象检测的建议(检测图像中的垃圾)
- javascript - NestJS 无法解析导入模块的依赖关系