Geo_disatance query via geo_shape filed


(Ahmad Azimi) #1

I have a geo_shape filed (MULTILINE type) which was named line in my documents and I wanna do a geo_disatance query against it to find all documents which are near a location (lat/lon)

PS. The line field is a MULTILINE geo type and if the desired point is near that line (through all its length) the query must find it!


(Mark Walkom) #2

What do you mean by this exactly?


(Ahmad Azimi) #3

I mean I have a filed in my document with type of geo_shape and I put inside that field a MULTILINESTRING geometry! It's described here:

https://www.elastic.co/guide/en/elasticsearch/reference/6.2/geo-shape.html#_ulink_url_http_www_geojson_org_geojson_spec_html_id6_multilinestring_ulink


(Mark Walkom) #4

Ok, so are you having issues with something? If you have a mapping and a query you can show it'd help


(Ahmad Azimi) #5

The mapping is simple!

'shape'           => [
    'type' => 'geo_shape',
],

But I don't know how to query!
I have a point as an input (a lat/lon) then I need to find the nearest line (multiple lat/lon) to that point. Lines saved as MULTILINESTRING but I guess Elastic cannot query to find nearest line and just able to find nearest point. Because of it I have to use centroid point of the line which is not my desired solution and response is not what need.


(system) #6

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