# Point in polygon search

**URL:** <https://discuss.elastic.co/t/point-in-polygon-search/6613>\
**Category:** Elasticsearch\
**Created:** [February 7, 2012, 5:33am UTC](https://discuss.elastic.co/t/point-in-polygon-search/6613 "2012-02-07T05:33:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dave\_Kinkead](https://avatars.discourse-cdn.com/v4/letter/d/a87d85/32.png) [@Dave\_Kinkead](https://discuss.elastic.co/u/Dave_Kinkead)\
**Post date:** [February 7, 2012, 5:33am UTC](https://discuss.elastic.co/t/point-in-polygon-search/6613/1 "2012-02-07T05:33:57Z")

</div>

Hi,

I'm looking for advice (or direction to advice) for the best way to  
perform point in polygon searches. My document store holds complex  
polygons and the search criteria will be a single geopoint (to return  
any polygons it is bounded by). My questions are:

1. is there any native geofilter for point in polygon? They all seem  
to search stored geopoints on polygon criteria (I want the opposite)

Assuming no, I was planning on returning any polygons that contain  
points north + south + east + west of the search geopoint, then doing  
a ray-cast in the application to determine results exactly. In this  
case:

1. how much additional performance would storing an additional minimum  
bounded box coords (eg just North West, South East) & searching just  
that vs search on the entire polygons? Im guessing the MBB would  
return more results but be faster?

2. is there any benefit of storing the polygon coords as geopoint  
types if I'm not going to be using the native geo filters?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [February 7, 2012, 11:59am UTC](https://discuss.elastic.co/t/point-in-polygon-search/6613/2 "2012-02-07T11:59:21Z")

</div>

On Tuesday, February 7, 2012 at 7:33 AM, Dave Kinkead wrote:

> Hi,
> 
> I'm looking for advice (or direction to advice) for the best way to  
> perform point in polygon searches. My document store holds complex  
> polygons and the search criteria will be a single geopoint (to return  
> any polygons it is bounded by). My questions are:
> 
> 1. is there any native geofilter for point in polygon? They all seem  
> to search stored geopoints on polygon criteria (I want the opposite)

No, there is no support for storing polygons and then doing to the docs a point falls within it.

> Assuming no, I was planning on returning any polygons that contain  
> points north + south + east + west of the search geopoint, then doing  
> a ray-cast in the application to determine results exactly. In this  
> case:
> 
> 1. how much additional performance would storing an additional minimum  
> bounded box coords (eg just North West, South East) & searching just  
> that vs search on the entire polygons? Im guessing the MBB would  
> return more results but be faster?

the less checks you will have the better. You mean storing the bbox in the document,  
and checking if the point falls within that bbox?

> 1. is there any benefit of storing the polygon coords as geopoint  
> types if I'm not going to be using the native geo filters?

You mean indexing them as double types, and doing range query on them? Then there  
isn't really a need for the geo type.

> Thanks in advance.

---

<div class="post-metadata">

**Author:** ![abinns](https://avatars.discourse-cdn.com/v4/letter/a/3be4f8/32.png) [@abinns](https://discuss.elastic.co/u/abinns)\
**Post date:** [October 14, 2013, 5:44pm UTC](https://discuss.elastic.co/t/point-in-polygon-search/6613/3 "2013-10-14T17:44:00Z")

</div>

On Tuesday, February 7, 2012 3:59:21 AM UTC-8, kimchy wrote:

> On Tuesday, February 7, 2012 at 7:33 AM, Dave Kinkead wrote:
> 
> 1. is there any native geofilter for point in polygon? They all seem  
> to search stored geopoints on polygon criteria (I want the opposite)
> 
> No, there is no support for storing polygons and then doing to the docs a  
> point falls within it.

Just wondering if this was still the case. Are there any new features or  
changes to the ES geospatial API since Feb 2012 that now makes this  
possible?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:** [July 6, 2017, 2:12am UTC](https://discuss.elastic.co/t/point-in-polygon-search/6613/4 "2017-07-06T02:12:33Z")

</div>


