DocumentDB 的空间索引

Spatial Indexes with DocumentDB

我正在尝试对 DocumentDB 进行空间查询,如下所示:

SELECT * FROM root r WHERE 
   ST_WITHIN({'type':'Point','coordinates':[-122.02625, 37.4718]}, r.boundingBox)

以匹配集合中看起来像这样的文档:

{
 "userId": "747941cfb829",
 "id": "747941cfb829_1453640096710",
 "boundingBox": {
   "type": "Polygon",
   "coordinates": [
     [-122.0263, 37.9718],
     [-122.0262, 37.9718],
     [-122.0262, 36.9718],
     [-122.0263, 36.9718],
     [-122.0263, 37.9718]
   ]
 },
 "distance": 0,
 "duration": 1
}

我已经打开了空间索引 ala https://azure.microsoft.com/en-us/documentation/articles/documentdb-geospatial/ 但我没有从 DocumentDB 得到匹配项。

有什么想法吗?

注意:更正了 GeoJson 坐标顺序。

GeoJSON 多边形的正确规范在坐标周围有一个额外的数组,而不是您显示的数组,以允许存在孔和多多边形的可能性。所以,它看起来像这样:

{
  "type": "Polygon",
  "coordinates": [
    [
      [0, 0], [10, 10], [10, 0], [0, 0]
    ]
  ]
}