# Geo\_disatance query via geo\_shape filed

**URL:** <https://discuss.elastic.co/t/geo-disatance-query-via-geo-shape-filed/132561>\
**Category:** Elasticsearch\
**Created:** [May 19, 2018, 8:17am UTC](https://discuss.elastic.co/t/geo-disatance-query-via-geo-shape-filed/132561 "2018-05-19T08:17:02Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ahmadazimi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ahmadazimi/32/25247_2.png) [@ahmadazimi](https://discuss.elastic.co/u/ahmadazimi)\
**Post date:** [May 19, 2018, 8:17am UTC](https://discuss.elastic.co/t/geo-disatance-query-via-geo-shape-filed/132561/1 "2018-05-19T08:17:02Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [May 20, 2018, 8:20am UTC](https://discuss.elastic.co/t/geo-disatance-query-via-geo-shape-filed/132561/2 "2018-05-20T08:20:22Z")

</div>

> [@ahmadazimi](#):
>
> I have a geo\_shape filed (MULTILINE type)

What do you mean by this exactly?

---

<div class="post-metadata">

**Author:** ![ahmadazimi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ahmadazimi/32/25247_2.png) [@ahmadazimi](https://discuss.elastic.co/u/ahmadazimi)\
**Post date:** [May 20, 2018, 9:35am UTC](https://discuss.elastic.co/t/geo-disatance-query-via-geo-shape-filed/132561/3 "2018-05-20T09:35:29Z")

</div>

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](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)

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [May 20, 2018, 9:38am UTC](https://discuss.elastic.co/t/geo-disatance-query-via-geo-shape-filed/132561/4 "2018-05-20T09:38:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ahmadazimi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ahmadazimi/32/25247_2.png) [@ahmadazimi](https://discuss.elastic.co/u/ahmadazimi)\
**Post date:** [May 20, 2018, 11:23am UTC](https://discuss.elastic.co/t/geo-disatance-query-via-geo-shape-filed/132561/5 "2018-05-20T11:23:37Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 17, 2018, 11:23am UTC](https://discuss.elastic.co/t/geo-disatance-query-via-geo-shape-filed/132561/6 "2018-06-17T11:23:46Z")

</div>

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