Issue 1:
Elasticsearch version: 2.3.3, 1.4.4

Plugins installed: not related

JVM version: 1.8.0_77

OS version: OS X El Capitan

Description of the problem including expected versus actual behavior:

In ES 2.3.3, if you do a geo polygon query whose one side lies on the equator in the south hemisphere, then you cannot find the indexed point on the equator. The query will work fine if the polygon is across the equator. Interestingly, this bug also exists in ES 1.4.4 but only happens when your polygon is in the north hemisphere.

I searched ES docs but there is no clear definition whether a geo point on the boundary of the geo polygon should be considered searchable or not. Is it considered as undefined behavior or is there any special rules about geo points on edges? It will be really helpful if you can edit ES docs to clarify this case.

Steps to reproduce:

Create an index with mapping:

PUT /geo_polygon
{
"settings" : {
"index" : {
"number_of_shards" : 1,
"number_of_replicas" : 0
}
},

"mappings": {
"my_type": {
"properties": {
"location": {
"type": "geo_point"
}
}
}
}
}

Put a list of points on the map.

PUT /geo_polygon/my_type/1
{
"text": "Point on the equator",
"location": {
"lat": 0.0,
"lon": 30.0
}
}

PUT /geo_polygon/my_type/2
{
"text": "Point in the southern hemisphere",
"location": {
"lat": -0.1,
"lon": 30.0
}
}

PUT /geo_polygon/my_type/3
{
"text": "Point in the northern hemisphere",
"location": {
"lat": 0.1,
"lon": 30.0
}
}

Search with a square polygon whose one side is on the equator in the southern hemisphere.

GET /geo_polygon
{
"query": {
"bool" : {
"filter" : {
"geo_polygon" : {
"location" : {
"points" : [
{"lat" : 0.0, "lon" : 10},
{"lat" : 0.0, "lon" : 50},
{"lat" : -1, "lon" : 50},
{"lat" : -1, "lon" : 10}
]
}
}
}
}
}
}

Result:

ES 2.3.3: only point 2 is returned.

ES 1.4.4: both point 1 and 2 are returned.

Search with a square polygon whose one side is on the equator in the northern hemisphere.

GET /geo_polygon
{
"query": {
"bool" : {
"filter" : {
"geo_polygon" : {
"location" : {
"points" : [
{"lat" : 0.0, "lon" : 10},
{"lat" : 0.0, "lon" : 50},
{"lat" : 1, "lon" : 50},
{"lat" : 1, "lon" : 10}
]
}
}
}
}
}
}

Result:

ES 2.3.3: both point 1 and 2 are returned.

ES 1.4.4: only point 2 is returned.

Search with a square polygon which is across the equator.

GET /geo_polygon
{
"query": {
"bool" : {
"filter" : {
"geo_polygon" : {
"location" : {
"points" : [
{"lat" : -1, "lon" : 10},
{"lat" : -1, "lon" : 50},
{"lat" : 1, "lon" : 50},
{"lat" : 1, "lon" : 10}
]
}
}
}
}
}
}

Result:

ES 2.3.3: all points 1, 2 and 3 are returned.

ES 1.4.4: all points 1, 2 and 3 are returned.

Provide logs (if relevant):

Describe the feature:

Issue 2:
Elasticsearch version: 2.3.3

Plugins installed: nothing

JVM version: 1.8.0_77

OS version: OS X El Captain 10.11.5

Description of the problem including expected versus actual behavior:

I found a bug when testing geo polygon search across the prime meridian (the 0 longitude). It cannot find the geo point inside the polygon whose longitude is smaller than 1.4 on the eastern hemisphere (positive longitude). Also, it's a regression because those points can be found on ES 1.4.4.

Steps to reproduce:

Create an index with mapping:

PUT /geo_polygon
{
"settings" : {
"index" : {
"number_of_shards" : 1,
"number_of_replicas" : 0
}
},

"mappings": {
"my_type": {
"properties": {
"location": {
"type": "geo_point"
}
}
}
}
}

Put a list of points on the map. I put all the points on the north hemisphere to eliminate the possible affect from latitude.

PUT /geo_polygon/my_type/1
{
"text": "Point on the prime meridian",
"location": {
"lat": 30,
"lon": 0
}
}

PUT /geo_polygon/my_type/2
{
"text": "Point very close to the prime meridian, eastern hemisphere",
"location": {
"lat": 30,
"lon": 0.1
}
}

PUT /geo_polygon/my_type/3
{
"text": "Point very close to the prime meridian, western hemisphere",
"location": {
"lat": 30,
"lon": -0.1
}
}

PUT /geo_polygon/my_type/4
{
"text": "Point close to the prime meridian, eastern hemisphere",
"location": {
"lat": 30,
"lon": 1.4
}
}

PUT /geo_polygon/my_type/5
{
"text": "Point close to the prime meridian, western hemisphere",
"location": {
"lat": 30,
"lon": -1.4
}
}

PUT /geo_polygon/my_type/6
{
"text": "Point close to the prime meridian on eastern hemisphere, different latitude",
"location": {
"lat": 25,
"lon": 1.4
}
}

PUT /geo_polygon/my_type/7
{
"text": "Point close to the prime meridian on western hemisphere, different latitude",
"location": {
"lat": 25,
"lon": -1.4
}
}

PUT /geo_polygon/my_type/8
{
"text": "Point not too far from the prime meridian",
"location": {
"lat": 30,
"lon": 1.5
}
}

PUT /geo_polygon/my_type/9
{
"text": "Point far from the prime meridian",
"location": {
"lat": 30,
"lon": 20
}
}

PUT /geo_polygon/my_type/10
{
"text": "Point quite far from the prime meridian",
"location": {
"lat": 30,
"lon": 90
}
}

Search in the following polygon:

GET /geo_polygon
{
"query": {
"bool" : {
"filter" : {
"geo_polygon" : {
"location" : {
"points" : [
{"lat" : 45, "lon" : 45},
{"lat" : 45, "lon" : -45},
{"lat" : 10, "lon" : 0}
]
}
}
}
}
}
}

Expected: points 1~9 should be found. The very far point 10 shouldn't be returned.

Actual: only point 3, 5, 7, 8, 9 are found, which have the following characteristic:

On the western hemisphere (lon < 0)

Or, the longitude is larger than 1.5.

Tried the same thing on ES 1.4 cluster and it could find point 1~9 correctly.

Currently I could mitigate this problem by splitting the polygon along the prime meridian and do a conjunctive search like the request below. It could find point 1~9 on ES 2.3.3 stack.

```
{
"query": {
"bool" : {
"should" : [
{
"bool": {
"filter" : {
"geo_polygon" : {
"location" : {
"points" : [
{"lat" : 45, "lon" : 45},
{"lat" : 45, "lon" : 0},
{"lat" : 10, "lon" : 0}
]
}
}
}
}
},
{
"bool": {
"filter" : {
"geo_polygon" : {
"location" : {
"points" : [
{"lat" : 45, "lon" : 0},
{"lat" : 45, "lon" : -45},
{"lat" : 10, "lon" : 0}
]
}
}
}
}
}
]
}
}
}
```

Interestingly, I tried to mirror the polygon above to the south hemisphere and search in the mirrored hemisphere. Instead of find nothing, I found points 1, 2, 4, 6, 8 and 9, which are all the points on non-western hemisphere.