在Azure搜索索引中搜索距参考点x公里以内的文档,其中x是文档上的字段 [英] Search Azure Search Index for documents within x km of the reference point where x is a field on the document

查看:78
本文介绍了在Azure搜索索引中搜索距参考点x公里以内的文档,其中x是文档上的字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Azure搜索索引中搜索不仅在搜索参考点x公里以内的文档,而且还在文档+ y km在搜索参考点x公里以内的文档中. y是文档上的一个字段,因此索引中的每个文档都会有所不同.

I am trying to search the Azure Search Index for documents that are not just within x km of the search reference point but also where the document + y km is within x km of the search reference. y is a field on the document so it will be different for each document in the index.

推荐答案

要基于参考点与文档中字段给出的点之间的距离查找过滤器,可以在$中使用geo.distance函数.过滤查询.例如,如果您的地理位置位于位置"字段中,则可以使用以下子句过滤到距离该点10公里以内的所有结果:

To find filter based on the distance between a reference point and a point given by a field in the document, you can use the geo.distance function in your $filter query. For instance if your geo point was in the field "location", you could filter to all results that are within 10km of that point with the following clause:

$filter=geo.distance(location, geography'POINT(-122.131577 47.678581)') le 10  

Azure搜索还通过使用geo.intersects函数指定边界多边形来支持地理过滤:

Azure Search also supports geo filtering by specifying a bounding polygon using the geo.intersects function:

$filter=geo.intersects(location, geography'POLYGON((-122.031577 47.578581, -122.031577 47.678581, -122.131577 47.678581, -122.031577 47.578581))')

如果您正在查找当前不支持的类似geo.distance(...) lt someOtherField之类的东西.

If you're looking for something like geo.distance(...) lt someOtherField that is currently unsupported.

从您的问题看来,您似乎在文档中有一个字段,并且要检查一个静态点,并按一定范围内的所有文档进行过滤.这应该可以通过geo.distance实现.如果这不能解决您的问题,您能否提供更多详细信息,或者也许是您要解决的问题的具体示例?

From your question it sounds like you have a field in the document, and a static point that you'd like to check against, filtering by all documents that are within a certain range. This should be achievable with geo.distance. If this doesn't cover your scenario, can you provide more details and perhaps a concrete example of the problem you're trying to solve?

您可以在 查看全文

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