elastic / elasticsearch

Free and Open Source, Distributed, RESTful Search Engine
https://www.elastic.co/products/elasticsearch
Other
1.23k stars 24.85k forks source link

Allow _geo_distance sort on geo_shape field type #68953

Open dw-alex opened 3 years ago

dw-alex commented 3 years ago

Now that geo_distance is enable for geo_shape field type (via #53466, #64326, and #64224) it would be great to allow _geo_distance sort on geo_shape field type.

elasticmachine commented 3 years ago

Pinging @elastic/es-analytics-geo (Team:Analytics)

djptek commented 3 years ago

I'll hopefully have some bandwidth to fix https://github.com/elastic/elasticsearch/pull/66756 this week and next which is related to this

nreese commented 2 years ago

Until this is resolved, _geo_distance sort docs should be updated to clearly state that geo_shape is not supported.

Here is an example of how this API inconsistency between geo_distance geo_shape support and _geo_distance lack of geo_shape support causes user confusion and a poor experience.

thibaultclem commented 5 months ago

Hi @iverase @djptek. Do you know if this is still an open issue ? Or if any workaround is possible to sort by distance for geo_shape ? Thanks

djptek commented 5 months ago

@thibaultclem I'm not currently working on this - thoughts @iverase?

iverase commented 5 months ago

It is still an open issue. It is a tricky one because while we compute distance using spherical mathematics, our shapes are not spherical, e.g edges are not big circles. Therefore we need to add new functionality that is still not there.

You can sort using the geo-shape centroid but I understand it is not the same and results can be surpising.

thibaultclem commented 5 months ago

Thanks a lot for your quick answer. Yes I understand that it's not as simple as for geo-point. Unfortunately we cannot use the centroid... The issue is that biggest geo object (in our case buildings with huge footprint) are too disadvantaged compare to smaller one. I will keep follow this issue. Best