# Running geo\_shape queries on geo\_points

**URL:** <https://discuss.elastic.co/t/running-geo-shape-queries-on-geo-points/169744>\
**Category:** Elasticsearch\
**Created:** [February 24, 2019, 9:11pm UTC](https://discuss.elastic.co/t/running-geo-shape-queries-on-geo-points/169744 "2019-02-24T21:11:28Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![krambambuli](https://avatars.discourse-cdn.com/v4/letter/k/d78d45/32.png) [@krambambuli](https://discuss.elastic.co/u/krambambuli)\
**Post date:** [February 24, 2019, 9:11pm UTC](https://discuss.elastic.co/t/running-geo-shape-queries-on-geo-points/169744/1 "2019-02-24T21:11:29Z")

</div>

Hi, the forum already has a few questions related to this (some unfortunately unanswered) but I'm unsure what the best practice is: If I have geo\_points in my data on which I want to run geo\_shape queries, should I

- put the point in my document twice, once as shape, once as point,
- or is there some other way I don't know about? (transforming the type when running the query etc.)

Thanks.

---

<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:** [February 24, 2019, 9:13pm UTC](https://discuss.elastic.co/t/running-geo-shape-queries-on-geo-points/169744/2 "2019-02-24T21:13:57Z")

</div>

You mean you want to run intersects/contains/etc type queries on your point?

---

<div class="post-metadata">

**Author:** ![krambambuli](https://avatars.discourse-cdn.com/v4/letter/k/d78d45/32.png) [@krambambuli](https://discuss.elastic.co/u/krambambuli)\
**Post date:** [February 24, 2019, 9:33pm UTC](https://discuss.elastic.co/t/running-geo-shape-queries-on-geo-points/169744/3 "2019-02-24T21:33:13Z")

</div>

Yes, exactly, though I guess the query I'm most interested in is a geo\_shape query with "within" as the relation.

---

<div class="post-metadata">

**Author:** ![Ignacio\_Vera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ignacio_vera/32/36674_2.png) [@Ignacio\_Vera](https://discuss.elastic.co/u/Ignacio_Vera)\
**Post date:** [February 25, 2019, 8:03am UTC](https://discuss.elastic.co/t/running-geo-shape-queries-on-geo-points/169744/4 "2019-02-25T08:03:56Z")

</div>

I don't understand the problem here. Intersects and within when querying for points are basically equivalent, and intersects normally runs much faster. Why do you thing you need geo\_shape queries in this case?

---

<div class="post-metadata">

**Author:** ![krambambuli](https://avatars.discourse-cdn.com/v4/letter/k/d78d45/32.png) [@krambambuli](https://discuss.elastic.co/u/krambambuli)\
**Post date:** [February 25, 2019, 8:48am UTC](https://discuss.elastic.co/t/running-geo-shape-queries-on-geo-points/169744/5 "2019-02-25T08:48:17Z")

</div>

Maybe I'm not understanding the documentation correctly, sorry for any confusion caused by this.

I have documents with a location field. What I would like to do is to run a query to find out for which documents the location falls within a given shape. If I understand the documentation correctly, my options for this are `geo_polygon` or `geo_shape` queries.

Since my shapes are quite big and will be reused, I'd rather have them indexed instead of putting them directly into the query. As far as I can see, `geo_polygon` queries don't support that. So I have to use `geo_shape` queries which ask for the field to be filtered on to be mapped to type `geo_shape` (as per the documentation).

Since I also want the option to run `geo_distance`queries, I need my locations as `geo_point`s too.

Happy to learn that the above is not correct and life is simpler than it seems.

---

<div class="post-metadata">

**Author:** ![Ignacio\_Vera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ignacio_vera/32/36674_2.png) [@Ignacio\_Vera](https://discuss.elastic.co/u/Ignacio_Vera)\
**Post date:** [February 25, 2019, 9:00am UTC](https://discuss.elastic.co/t/running-geo-shape-queries-on-geo-points/169744/6 "2019-02-25T09:00:53Z")

</div>

Thanks for the explanation. Querying by indexed shapes is only supported for geo\_shapes. My recommendation in that cases would be to use intersects as a relationship as it is faster than within.

Not sure if indexing the shapes is the best strategy here, geo\_polygon queries are the most efficient ones, so you might want to test if the strategy gives you the performance and accuracy that you 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:** [March 25, 2019, 9:00am UTC](https://discuss.elastic.co/t/running-geo-shape-queries-on-geo-points/169744/7 "2019-03-25T09:00:57Z")

</div>

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