Geographic direction correspondence

Hi, I could use your help writing a query.

I use polygon searching using geo_polygon and it works very well, however I would like to refine the search results to receive only hits that would be in the same direction as my search.

In a user search, I determine a bearing which is a number between 0 and 360.
On the Elasticsearch side, I also have a bearing field.

I would like the search to filter the results that would have a bearing of more or less 90° (around a circle so reset to zero if greater than 360).

I hope I've made myself clear, if not, feel free to ask me for more details.

I thank you in advance

Unless I am fundamentally misunderstand the requirement regarding the bearing, this sounds like a boolean query with two clauses in the must part. One for the bearing and one for the geo polygon query.

See https://www.elastic.co/guide/en/elasticsearch/reference/7.5/query-dsl-bool-query.html

Indeed, I managed to find a solution to my problem by putting a condition, the request must be should in the case where minBearing and maxBearing included 360° and in must the opposite case.

minBearing = bearing - 90°
maxBearing = bearing + 90°

Thank you for your response

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.