文档数据库-ST_DISTANCE [英] Document DB - ST_DISTANCE

查看:105
本文介绍了文档数据库-ST_DISTANCE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否会像

SELECT TOP 1 * ST_DISTANCE etc 

或更具体地说

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?

谢谢

伊恩

推荐答案

DocumentDB本身还不支持使用地理空间索引进行最近或ORDER BY.

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

ORDER BY的最佳方法是在查询中投影(SELECT)距离,然后在客户端或通过存储过程对其进行排序(以减少多次往返的等待时间).

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).

对于较大的数据集,您可以通过从小值开始在距离上添加过滤器(WHERE),然后迭代/逐步增加距离值直到找到第一个点,来优化最接近距离.

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.

这篇关于文档数据库-ST_DISTANCE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆