Search Azure Search Index for documents within x km of the reference point where x is a field on the document

帅比萌擦擦* 提交于 2019-12-12 06:45:39

问题


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.


回答1:


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

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

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?

You can find more information about odata filtering using geo.distance and geo.intersects in the Azure Search OData syntax documentation



来源:https://stackoverflow.com/questions/44806755/search-azure-search-index-for-documents-within-x-km-of-the-reference-point-where

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