Documentdb - GeoSpatial 返回空行
Documentdb - GeoSpatial returning empty rows
ST_WITHIN 没有给出结果,总是 return 零条记录。
示例如下:
select *
FROM Areas a
WHERE ST_WITHIN({'type': 'Point', 'coordinates':[31.9, -4.8]}, a.location)
期望上面的查询应该return一条记录。
我的数据库条目是
{
"id": "MyDesignatedLocation",
"location": {
"type": "Polygon",
"coordinates": [
[
[
31.8,
-5
],
[
32,
-5
],
[
32,
-4.7
],
[
31.8,
-4.7
],
[
31.8,
-5
]
]
]
}
}
默认情况下,DocumentDB returns 仅针对已编制索引的路径-数据类型组合生成结果。根据您的描述,您似乎没有为空间索引包含多边形(在投影中,结果将通过扫描返回)。
为了返回结果,请更改索引策略以在多边形数据类型上包含空间索引(请参阅下面的示例索引策略)。此处有更多详细信息: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":[
]
}
ST_WITHIN 没有给出结果,总是 return 零条记录。
示例如下:
select *
FROM Areas a
WHERE ST_WITHIN({'type': 'Point', 'coordinates':[31.9, -4.8]}, a.location)
期望上面的查询应该return一条记录。
我的数据库条目是
{
"id": "MyDesignatedLocation",
"location": {
"type": "Polygon",
"coordinates": [
[
[
31.8,
-5
],
[
32,
-5
],
[
32,
-4.7
],
[
31.8,
-4.7
],
[
31.8,
-5
]
]
]
}
}
默认情况下,DocumentDB returns 仅针对已编制索引的路径-数据类型组合生成结果。根据您的描述,您似乎没有为空间索引包含多边形(在投影中,结果将通过扫描返回)。
为了返回结果,请更改索引策略以在多边形数据类型上包含空间索引(请参阅下面的示例索引策略)。此处有更多详细信息: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":[
]
}