# 4 point polygon search for over half the world results in incorrect (opposite) polygon to be searched

**URL:** <https://discuss.elastic.co/t/4-point-polygon-search-for-over-half-the-world-results-in-incorrect-opposite-polygon-to-be-searched/13402>\
**Category:** Elasticsearch\
**Created:** [August 29, 2013, 11:07pm UTC](https://discuss.elastic.co/t/4-point-polygon-search-for-over-half-the-world-results-in-incorrect-opposite-polygon-to-be-searched/13402 "2013-08-29T23:07:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nateweisiger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nateweisiger/32/2130_2.png) [@nateweisiger](https://discuss.elastic.co/u/nateweisiger)\
**Post date:** [August 29, 2013, 11:07pm UTC](https://discuss.elastic.co/t/4-point-polygon-search-for-over-half-the-world-results-in-incorrect-opposite-polygon-to-be-searched/13402/1 "2013-08-29T23:07:03Z")

</div>

Hello,

We are running into an issue that I hope someone can help out with. Small polygons (LESS than the length of 1/2 of the world from east to west) work fine.

Once we increase the size of the polygon to a larger size (say, 2/3 the size of the globe east to west) the results are returned with the OPPOSITE polygon. (Upper right becomes upper left, lower right becomes lower left). I understand why this is happening. Elasticsearch is talking 4 points, and when wrapping the other way creates a smaller polygon than the one intended, it uses that one.

For example:  
The following search works just fine  
\<nabble\_img src="example1.png" border="0" alt="Works Fine"/\>

This one DOES NOT work. It assumes the polygon I want is from the upper left to the upper right (wrapping around the other side of the map).  
\<nabble\_img src="World\_Map\_-\_UrtheCast.png" border="0" alt="Does not work"/\>

I want results from the purple box, but it is returning results from the red box.

Has anyone ran into this issue? If so, how does one solve this? We have tried passing the points in a different order, but no matter what was tried, it always assumes the smallest polygon.

SIDE NOTE: When we use "envelope", it works fine, bit polygon support is needed.

Thanks!  
Nate

---

<div class="post-metadata">

**Author:** ![nateweisiger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nateweisiger/32/2130_2.png) [@nateweisiger](https://discuss.elastic.co/u/nateweisiger)\
**Post date:** [September 4, 2013, 12:02am UTC](https://discuss.elastic.co/t/4-point-polygon-search-for-over-half-the-world-results-in-incorrect-opposite-polygon-to-be-searched/13402/2 "2013-09-04T00:02:04Z")

</div>

Bump...

Anyone have any ideas? I'd be surprised if I was the only one who has come  
across this. If you need more info, let me know.

Thanks!  
Nate

On Thursday, August 29, 2013 4:07:04 PM UTC-7, nateweisiger wrote:

> Hello,
> 
> We are running into an issue that I hope someone can help out with. Small  
> polygons (LESS than the length of 1/2 of the world from east to west) work  
> fine.
> 
> Once we increase the size of the polygon to a larger size (say, 2/3 the  
> size  
> of the globe east to west) the results are returned with the OPPOSITE  
> polygon. (Upper right becomes upper left, lower right becomes lower left).  
> I  
> understand why this is happening. Elasticsearch is talking 4 points, and  
> when wrapping the other way creates a smaller polygon than the one  
> intended,  
> it uses that one.
> 
> For example:  
> The following search works just fine  
> \<  
> [http://elasticsearch-users.115913.n3.nabble.com/file/n4040367/example1.png](http://elasticsearch-users.115913.n3.nabble.com/file/n4040367/example1.png)\>
> 
> This one DOES NOT work. It assumes the polygon I want is from the upper  
> left  
> to the upper right (wrapping around the other side of the map).  
> \<  
> [http://elasticsearch-users.115913.n3.nabble.com/file/n4040367/World\_Map\_-\_UrtheCast.png](http://elasticsearch-users.115913.n3.nabble.com/file/n4040367/World_Map_-_UrtheCast.png)\>
> 
> I want results from the purple box, but it is returning results from the  
> red  
> box.
> 
> Has anyone ran into this issue? If so, how does one solve this? We have  
> tried passing the points in a different order, but no matter what was  
> tried,  
> it always assumes the smallest polygon.
> 
> SIDE NOTE: When we use "envelope", it works fine, bit polygon support is  
> needed.
> 
> Thanks!  
> Nate
> 
> --  
> View this message in context:  
> [http://elasticsearch-users.115913.n3.nabble.com/4-point-polygon-search-for-over-half-the-world-results-in-incorrect-opposite-polygon-to-be-searched-tp4040367.html](http://elasticsearch-users.115913.n3.nabble.com/4-point-polygon-search-for-over-half-the-world-results-in-incorrect-opposite-polygon-to-be-searched-tp4040367.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

--  
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:** ![chilling](https://avatars.discourse-cdn.com/v4/letter/c/b3f665/32.png) [@chilling](https://discuss.elastic.co/u/chilling)\
**Post date:** [September 4, 2013, 10:00am UTC](https://discuss.elastic.co/t/4-point-polygon-search-for-over-half-the-world-results-in-incorrect-opposite-polygon-to-be-searched/13402/3 "2013-09-04T10:00:50Z")

</div>

Hi Nate,

thanks for posting this issue. Which version of ES are you using running  
into this?

-- Florian

On Wednesday, September 4, 2013 2:02:04 AM UTC+2, [nwei...@urthecast.com](mailto:nwei...@urthecast.com)  
wrote:

> Bump...
> 
> Anyone have any ideas? I'd be surprised if I was the only one who has come  
> across this. If you need more info, let me know.
> 
> Thanks!  
> Nate
> 
> On Thursday, August 29, 2013 4:07:04 PM UTC-7, nateweisiger wrote:
> 
> > Hello,
> > 
> > We are running into an issue that I hope someone can help out with. Small  
> > polygons (LESS than the length of 1/2 of the world from east to west)  
> > work  
> > fine.
> > 
> > Once we increase the size of the polygon to a larger size (say, 2/3 the  
> > size  
> > of the globe east to west) the results are returned with the OPPOSITE  
> > polygon. (Upper right becomes upper left, lower right becomes lower  
> > left). I  
> > understand why this is happening. Elasticsearch is talking 4 points, and  
> > when wrapping the other way creates a smaller polygon than the one  
> > intended,  
> > it uses that one.
> > 
> > For example:  
> > The following search works just fine  
> > \<  
> > [http://elasticsearch-users.115913.n3.nabble.com/file/n4040367/example1.png](http://elasticsearch-users.115913.n3.nabble.com/file/n4040367/example1.png)\>
> > 
> > This one DOES NOT work. It assumes the polygon I want is from the upper  
> > left  
> > to the upper right (wrapping around the other side of the map).  
> > \<  
> > [http://elasticsearch-users.115913.n3.nabble.com/file/n4040367/World\_Map\_-\_UrtheCast.png](http://elasticsearch-users.115913.n3.nabble.com/file/n4040367/World_Map_-_UrtheCast.png)\>
> > 
> > I want results from the purple box, but it is returning results from the  
> > red  
> > box.
> > 
> > Has anyone ran into this issue? If so, how does one solve this? We have  
> > tried passing the points in a different order, but no matter what was  
> > tried,  
> > it always assumes the smallest polygon.
> > 
> > SIDE NOTE: When we use "envelope", it works fine, bit polygon support is  
> > needed.
> > 
> > Thanks!  
> > Nate
> > 
> > --  
> > View this message in context:  
> > [http://elasticsearch-users.115913.n3.nabble.com/4-point-polygon-search-for-over-half-the-world-results-in-incorrect-opposite-polygon-to-be-searched-tp4040367.html](http://elasticsearch-users.115913.n3.nabble.com/4-point-polygon-search-for-over-half-the-world-results-in-incorrect-opposite-polygon-to-be-searched-tp4040367.html)  
> > Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

--  
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:** ![chilling](https://avatars.discourse-cdn.com/v4/letter/c/b3f665/32.png) [@chilling](https://discuss.elastic.co/u/chilling)\
**Post date:** [September 5, 2013, 7:51am UTC](https://discuss.elastic.co/t/4-point-polygon-search-for-over-half-the-world-results-in-incorrect-opposite-polygon-to-be-searched/13402/4 "2013-09-05T07:51:25Z")

</div>

Hi Nate,

is it also possible to post an example of the failing query?

--Florian

On Wednesday, September 4, 2013 12:00:50 PM UTC+2, Florian Schilling wrote:

> Hi Nate,
> 
> thanks for posting this issue. Which version of ES are you using running  
> into this?
> 
> -- Florian
> 
> On Wednesday, September 4, 2013 2:02:04 AM UTC+2, nwei...@urthecast.comwrote:
> 
> > Bump...
> > 
> > Anyone have any ideas? I'd be surprised if I was the only one who has  
> > come across this. If you need more info, let me know.
> > 
> > Thanks!  
> > Nate
> > 
> > On Thursday, August 29, 2013 4:07:04 PM UTC-7, nateweisiger wrote:
> > 
> > > Hello,
> > > 
> > > We are running into an issue that I hope someone can help out with.  
> > > Small  
> > > polygons (LESS than the length of 1/2 of the world from east to west)  
> > > work  
> > > fine.
> > > 
> > > Once we increase the size of the polygon to a larger size (say, 2/3 the  
> > > size  
> > > of the globe east to west) the results are returned with the OPPOSITE  
> > > polygon. (Upper right becomes upper left, lower right becomes lower  
> > > left). I  
> > > understand why this is happening. Elasticsearch is talking 4 points, and  
> > > when wrapping the other way creates a smaller polygon than the one  
> > > intended,  
> > > it uses that one.
> > > 
> > > For example:  
> > > The following search works just fine  
> > > \<  
> > > [http://elasticsearch-users.115913.n3.nabble.com/file/n4040367/example1.png](http://elasticsearch-users.115913.n3.nabble.com/file/n4040367/example1.png)\>
> > > 
> > > This one DOES NOT work. It assumes the polygon I want is from the upper  
> > > left  
> > > to the upper right (wrapping around the other side of the map).  
> > > \<  
> > > [http://elasticsearch-users.115913.n3.nabble.com/file/n4040367/World\_Map\_-\_UrtheCast.png](http://elasticsearch-users.115913.n3.nabble.com/file/n4040367/World_Map_-_UrtheCast.png)\>
> > > 
> > > I want results from the purple box, but it is returning results from the  
> > > red  
> > > box.
> > > 
> > > Has anyone ran into this issue? If so, how does one solve this? We have  
> > > tried passing the points in a different order, but no matter what was  
> > > tried,  
> > > it always assumes the smallest polygon.
> > > 
> > > SIDE NOTE: When we use "envelope", it works fine, bit polygon support is  
> > > needed.
> > > 
> > > Thanks!  
> > > Nate
> > > 
> > > --  
> > > View this message in context:  
> > > [http://elasticsearch-users.115913.n3.nabble.com/4-point-polygon-search-for-over-half-the-world-results-in-incorrect-opposite-polygon-to-be-searched-tp4040367.html](http://elasticsearch-users.115913.n3.nabble.com/4-point-polygon-search-for-over-half-the-world-results-in-incorrect-opposite-polygon-to-be-searched-tp4040367.html)  
> > > Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

--  
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:18am UTC](https://discuss.elastic.co/t/4-point-polygon-search-for-over-half-the-world-results-in-incorrect-opposite-polygon-to-be-searched/13402/5 "2017-07-06T02:18:05Z")

</div>


