Document DB - ST_DISTANCE

浪子不回头ぞ 提交于 2020-01-14 03:31:06

问题


Would a query like

SELECT TOP 1 * ST_DISTANCE etc 

or more specifically

SELECT TOP 1 * FROM c WHERE ST_DISTANCE(c.AssetLocation, { 'type': 'Point', 'coordinates': [115.58, 21.84] }) < 49999

return the closest object, and if not, how could I order by distance?

Thanks,

Ian


回答1:


DocumentDB does not natively support nearest or ORDER BY using Geo-Spatial index yet.

The best approach for ORDER BY is to project (SELECT) the distance in the query and sort it either client-side or via a stored procedure (reduces the latency cost of multiple round trips).

For a large data set, you can optimize nearest by adding a filter (WHERE) on distance beginning with a small value, and iterating / stepping through increasing distance values until the first points are found.



来源:https://stackoverflow.com/questions/37262001/document-db-st-distance

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!