Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Distance from [lon,lat] to geo_shape #13351

Closed
eskibars opened this issue Sep 4, 2015 · 22 comments · Fixed by #53466
Closed

Distance from [lon,lat] to geo_shape #13351

eskibars opened this issue Sep 4, 2015 · 22 comments · Fixed by #53466
Labels
:Analytics/Geo Indexing, search aggregations of geo points and shapes >enhancement release highlight v7.7.0 v8.0.0-alpha1

Comments

@eskibars
Copy link
Contributor

eskibars commented Sep 4, 2015

Currently, we can do distance math for filter (geo_distance) and sort (_geo_distance) from a given [lon,lat] to a geo_point. We cannot do this currently for a [lon,lat] to the surface of a geo_shape object (distance "N"). There's a bit of a workaround for the geo_distance filter: you can create a circle of a specified radius M and check for an "intersects" relation. However, there are some cases where this does not work (e.g. if M > (N + [span of geo_shape]) it's now "within").

A few examples:

  • A vehicle is supposed to follow an indexed LineString / MultiLineString path and we want to find when it has deviated from the path by more than 100 meters [filter]
  • Find the nearest landmark (geo-shape) to my present location [sort]
@eskibars eskibars added the :Analytics/Geo Indexing, search aggregations of geo points and shapes label Sep 4, 2015
@Ghost93
Copy link

Ghost93 commented Jan 9, 2016

Hi,
any news on this?

We also need geo_distance to support geo_shape fields.

@clintongormley
Copy link
Contributor

@nknize any thoughts on this?

@nknize
Copy link
Contributor

nknize commented Feb 1, 2016

This will likely follow the Lucene 5.5 release which includes the API and performance improvements needed to make this perform at scale.

@akamanocha
Copy link

+1 for this. I guess es is now on 5.5 any plan to do this.

Or suggested architecture/ workaround please?

@imalygin
Copy link

Do you have any updates for this by any chance?

@clintongormley
Copy link
Contributor

Not yet. A new geo field type is being worked on which combines geo-point and geo-shape functionality, but it is early days still

@jfitz1
Copy link

jfitz1 commented Nov 18, 2016

+1

3 similar comments
@kaxil
Copy link

kaxil commented Dec 8, 2016

+1

@riconegri
Copy link

+1

@juanpujol
Copy link

👍

@akamanocha
Copy link

Anything on this?

@publicaddm
Copy link

+1

1 similar comment
@lukas-gitl
Copy link

+1

@TomerGold1998
Copy link

+1 any update ??

@radeno
Copy link

radeno commented Feb 20, 2018

I dont want to be troll but even javascript (i work with it) has awesome library https://github.com/Turfjs/turf but high-scalabe technology doesn't.

@mgerasimchuk
Copy link

+1

@christian-froh
Copy link

+1

@jpountz
Copy link
Contributor

jpountz commented Sep 22, 2018

Some thoughts:

  • sorting (or aggregating) geo shapes is going to be at least controversial due to the fact that it requires storing shapes in doc values
  • filtering shapes by geo distance is going to be easy with the upcoming BKD-based shape support
  • filtering or sorting points by their distance to a (query) shape would be doable efficiently I believe, eg. by splitting the query shape into multiple sub shapes and partitioning the space based on their closest sub-shape so that we wouldn't have to consider the entire shape every time.

Let's maybe split this issue for these different use-cases?

@imotov
Copy link
Contributor

imotov commented Dec 10, 2018

Depends on #32039 and #37206

@blkbltjns
Copy link

blkbltjns commented Dec 17, 2019

We could really use this as the new BKD index methodology does not work with intersecting circles in latest ES, and intersecting with circles by converting to polygons is wasteful and inaccurate.

@talevy
Copy link
Contributor

talevy commented Dec 17, 2019

and intersecting with circles by converting to polygons is wasteful and inaccurate.

I am not sure this issue is the right place to have this discussion. but could you explain your use-case a bit more and what type of distance queries you are interested in doing?

@blkbltjns
Copy link

blkbltjns commented Dec 18, 2019

and intersecting with circles by converting to polygons is wasteful and inaccurate.

I am not sure this issue is the right place to have this discussion. but could you explain your use-case a bit more and what type of distance queries you are interested in doing?

Sure, and my apologies if this is the wrong thread for this. My use case is querying for arbitrary shapes (can be points, multipoints, geometrycollection, polygon, etc...) at a certain distance from a point (actually thousands of points, but we handle this with a bool query). Due to geo_distance only working point-to-point, the workaround way to do this used to be to intersect a circle shape with the relevant index containing the arbitrary shapes. However, due to 6.8’s BKD indexing methodology not working with circles and geoshape intersection, I am left with using the deprecated geohash or prefixtree indexing or turning the circles into polygons and intersecting those. Both these workarounds are not good in my opinion, and are really just backwards ways to do a basic distance filter between a point and a shape, which geo_distance currently doesn’t support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/Geo Indexing, search aggregations of geo points and shapes >enhancement release highlight v7.7.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging a pull request may close this issue.