ST_WITHIN没有给出结果,总是返回零记录。
这是一个例子:
select *
FROM Areas a
WHERE ST_WITHIN({'type': 'Point', 'coordinates':[31.9, -4.8]}, a.location)
期望上述查询应返回一条记录。
我的数据库条目是
{
"id": "MyDesignatedLocation",
"location": {
"type": "Polygon",
"coordinates": [
[
[
31.8,
-5
],
[
32,
-5
],
[
32,
-4.7
],
[
31.8,
-4.7
],
[
31.8,
-5
]
]
]
}
}
答案 0 :(得分:1)
默认情况下,DocumentDB仅为索引的路径数据类型组合返回结果。根据您的描述,您似乎没有包含空间索引的多边形(在投影中,结果将通过扫描返回)。
为了获得结果,请更改索引策略以在Polygon数据类型中包含Spatial索引(请参阅下面的示例索引策略)。更多详情:https://azure.microsoft.com/en-us/documentation/articles/documentdb-geospatial/
{
"automatic":true,
"indexingMode":"Consistent",
"includedPaths":[
{
"path":"/*",
"indexes":[
{
"kind":"Range",
"dataType":"String",
"precision":-1
},
{
"kind":"Range",
"dataType":"Number",
"precision":-1
},
{
"kind":"Spatial",
"dataType":"Point"
},
{
"kind":"Spatial",
"dataType":"Polygon"
}
]
}
],
"excludedPaths":[
]
}