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
]
]
]
}
}发布于 2016-11-01 16:37:12
默认情况下,DocumentDB只返回索引的路径数据类型组合的结果。根据您的描述,看起来您没有包含用于空间索引的多边形(在投影中,结果将通过扫描返回)。
为了返回结果,请将索引策略更改为包含多边形数据类型上的空间索引(参见下面的示例索引策略)。这里有更多详细信息: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":[
]
}https://stackoverflow.com/questions/40357029
复制相似问题