问题
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