<p dir="auto"><strong>Elasticsearch version</strong>: 2.3.3, 1.4.4</p>
<p dir="auto"><strong>Plugins installed</strong>: not related</p>
<p dir="auto"><strong>JVM version</strong>: 1.8.0_77</p>
<p dir="auto"><strong>OS version</strong>: OS X El Capitan</p>
<p dir="auto"><strong>Description of the problem including expected versus actual behavior</strong>:<br>
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.</p>
<p dir="auto">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.</p>
<p dir="auto"><strong>Steps to reproduce</strong>:</p>
<ol dir="auto">
<li>
<p dir="auto">Create an index with mapping:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="PUT /geo_polygon
{
    &quot;settings&quot; : {
        &quot;index&quot; : {
            &quot;number_of_shards&quot; : 1, 
            &quot;number_of_replicas&quot; : 0
        }
    },

  &quot;mappings&quot;: {
    &quot;my_type&quot;: {
      &quot;properties&quot;: {
        &quot;location&quot;: {
          &quot;type&quot;: &quot;geo_point&quot;
        }
      }
    }
  }
}"><pre class="notranslate"><code class="notranslate">PUT /geo_polygon
{
    "settings" : {
        "index" : {
            "number_of_shards" : 1, 
            "number_of_replicas" : 0
        }
    },

  "mappings": {
    "my_type": {
      "properties": {
        "location": {
          "type": "geo_point"
        }
      }
    }
  }
}
</code></pre></div>
</li>
<li>
<p dir="auto">Put a list of points on the map.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="PUT /geo_polygon/my_type/1
{
  &quot;text&quot;: &quot;Point on the equator&quot;,
  &quot;location&quot;: { 
    &quot;lat&quot;: 0.0,
    &quot;lon&quot;: 30.0
  }
}

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

PUT /geo_polygon/my_type/3
{
  &quot;text&quot;: &quot;Point in the northern hemisphere&quot;,
  &quot;location&quot;: { 
    &quot;lat&quot;: 0.1,
    &quot;lon&quot;: 30.0
  }
}"><pre class="notranslate"><code class="notranslate">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
  }
}
</code></pre></div>
</li>
<li>
<p dir="auto">Search with a square polygon whose one side is on the equator in the southern hemisphere.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="GET /geo_polygon
{
    &quot;query&quot;: {
        &quot;bool&quot; : {
            &quot;filter&quot; : {
                &quot;geo_polygon&quot; : {
                    &quot;location&quot; : {
                        &quot;points&quot; : [
                            {&quot;lat&quot; : 0.0, &quot;lon&quot; : 10},
                            {&quot;lat&quot; : 0.0, &quot;lon&quot; : 50},
                            {&quot;lat&quot; : -1, &quot;lon&quot; : 50},
                            {&quot;lat&quot; : -1, &quot;lon&quot; : 10}
                        ]
                    }
                }
            }
        }
    }
}"><pre class="notranslate"><code class="notranslate">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}
                        ]
                    }
                }
            }
        }
    }
}
</code></pre></div>
<p dir="auto">Result:</p>
<ul dir="auto">
<li>ES 2.3.3: only point 2 is returned.</li>
<li>ES 1.4.4: both point 1 and 2 are returned.</li>
</ul>
</li>
<li>
<p dir="auto">Search with a square polygon whose one side is on the equator in the northern hemisphere.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="GET /geo_polygon
{
    &quot;query&quot;: {
        &quot;bool&quot; : {
            &quot;filter&quot; : {
                &quot;geo_polygon&quot; : {
                    &quot;location&quot; : {
                        &quot;points&quot; : [
                            {&quot;lat&quot; : 0.0, &quot;lon&quot; : 10},
                            {&quot;lat&quot; : 0.0, &quot;lon&quot; : 50},
                            {&quot;lat&quot; : 1, &quot;lon&quot; : 50},
                            {&quot;lat&quot; : 1, &quot;lon&quot; : 10}
                        ]
                    }
                }
            }
        }
    }
}"><pre class="notranslate"><code class="notranslate">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}
                        ]
                    }
                }
            }
        }
    }
}
</code></pre></div>
<p dir="auto">Result:</p>
<ul dir="auto">
<li>ES 2.3.3: both point 1 and 2 are returned.</li>
<li>ES 1.4.4: only point 2 is returned.</li>
</ul>
</li>
<li>
<p dir="auto">Search with a square polygon which is across the equator.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="GET /geo_polygon
{
    &quot;query&quot;: {
        &quot;bool&quot; : {
            &quot;filter&quot; : {
                &quot;geo_polygon&quot; : {
                    &quot;location&quot; : {
                        &quot;points&quot; : [
                            {&quot;lat&quot; : -1, &quot;lon&quot; : 10},
                            {&quot;lat&quot; : -1, &quot;lon&quot; : 50},
                            {&quot;lat&quot; : 1, &quot;lon&quot; : 50},
                            {&quot;lat&quot; : 1, &quot;lon&quot; : 10}
                        ]
                    }
                }
            }
        }
    }
}"><pre class="notranslate"><code class="notranslate">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}
                        ]
                    }
                }
            }
        }
    }
}
</code></pre></div>
<p dir="auto">Result:</p>
<ul dir="auto">
<li>ES 2.3.3: all points 1, 2 and 3 are returned.</li>
<li>ES 1.4.4: all points 1, 2 and 3 are returned.</li>
</ul>
</li>
</ol>
<p dir="auto"><strong>Provide logs (if relevant)</strong>:</p>

<p dir="auto"><strong>Describe the feature</strong>:</p>
<p dir="auto"><strong>Elasticsearch version</strong>: 2.3.3</p>
<p dir="auto"><strong>Plugins installed</strong>: nothing</p>
<p dir="auto"><strong>JVM version</strong>: 1.8.0_77</p>
<p dir="auto"><strong>OS version</strong>: OS X El Captain 10.11.5</p>
<p dir="auto"><strong>Description of the problem including expected versus actual behavior</strong>:<br>
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.</p>
<p dir="auto"><strong>Steps to reproduce</strong>:</p>
<ol dir="auto">
<li>
<p dir="auto">Create an index with mapping:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="PUT /geo_polygon
{
    &quot;settings&quot; : {
        &quot;index&quot; : {
            &quot;number_of_shards&quot; : 1, 
            &quot;number_of_replicas&quot; : 0
        }
    },

  &quot;mappings&quot;: {
    &quot;my_type&quot;: {
      &quot;properties&quot;: {
        &quot;location&quot;: {
          &quot;type&quot;: &quot;geo_point&quot;
        }
      }
    }
  }
}"><pre class="notranslate"><code class="notranslate">PUT /geo_polygon
{
    "settings" : {
        "index" : {
            "number_of_shards" : 1, 
            "number_of_replicas" : 0
        }
    },

  "mappings": {
    "my_type": {
      "properties": {
        "location": {
          "type": "geo_point"
        }
      }
    }
  }
}
</code></pre></div>
</li>
<li>
<p dir="auto">Put a list of points on the map. I put all the points on the north hemisphere to eliminate the possible affect from latitude.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="PUT /geo_polygon/my_type/1
{
  &quot;text&quot;: &quot;Point on the prime meridian&quot;,
  &quot;location&quot;: { 
    &quot;lat&quot;: 30,
    &quot;lon&quot;: 0
  }
}

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

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

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

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

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

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

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

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

PUT /geo_polygon/my_type/10
{
  &quot;text&quot;: &quot;Point quite far from the prime meridian&quot;,
  &quot;location&quot;: { 
    &quot;lat&quot;: 30,
    &quot;lon&quot;: 90
  }
}"><pre class="notranslate"><code class="notranslate">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
  }
}
</code></pre></div>
</li>
<li>
<p dir="auto">Search in the following polygon:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="GET /geo_polygon
{
    &quot;query&quot;: {
        &quot;bool&quot; : {
            &quot;filter&quot; : {
                &quot;geo_polygon&quot; : {
                    &quot;location&quot; : {
                        &quot;points&quot; : [
                            {&quot;lat&quot; : 45, &quot;lon&quot; : 45},
                            {&quot;lat&quot; : 45, &quot;lon&quot; : -45},
                            {&quot;lat&quot; : 10, &quot;lon&quot; : 0}
                        ]
                    }
                }
            }
        }
    }
}"><pre class="notranslate"><code class="notranslate">GET /geo_polygon
{
    "query": {
        "bool" : {
            "filter" : {
                "geo_polygon" : {
                    "location" : {
                        "points" : [
                            {"lat" : 45, "lon" : 45},
                            {"lat" : 45, "lon" : -45},
                            {"lat" : 10, "lon" : 0}
                        ]
                    }
                }
            }
        }
    }
}
</code></pre></div>
</li>
</ol>
<p dir="auto">Expected: points 1~9 should be found. The very far point 10 shouldn't be returned.<br>
Actual: only point 3, 5, 7, 8, 9 are found, which have the following characteristic:</p>
<ol dir="auto">
<li>On the western hemisphere (lon &lt; 0)</li>
<li>Or, the longitude is larger than 1.5.</li>
</ol>
<p dir="auto">Tried the same thing on ES 1.4 cluster and it could find point 1~9 correctly.</p>
<p dir="auto">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.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="```
{
    &quot;query&quot;: {
        &quot;bool&quot; : {
            &quot;should&quot; : [
                {
                    &quot;bool&quot;: {
                        &quot;filter&quot; : {
                            &quot;geo_polygon&quot; : {
                                &quot;location&quot; : {
                                    &quot;points&quot; : [
                                        {&quot;lat&quot; : 45, &quot;lon&quot; : 45},
                                        {&quot;lat&quot; : 45, &quot;lon&quot; : 0},
                                        {&quot;lat&quot; : 10, &quot;lon&quot; : 0}
                                    ]
                                }
                            }
                        }
                    }
                },
                {
                    &quot;bool&quot;: {
                        &quot;filter&quot; : {
                            &quot;geo_polygon&quot; : {
                                &quot;location&quot; : {
                                    &quot;points&quot; : [
                                        {&quot;lat&quot; : 45, &quot;lon&quot; : 0},
                                        {&quot;lat&quot; : 45, &quot;lon&quot; : -45},
                                        {&quot;lat&quot; : 10, &quot;lon&quot; : 0}
                                    ]
                                }
                            }
                        }
                    }
                }
            ]
        }
    }
}
```"><pre class="notranslate"><code class="notranslate">```
{
    "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}
                                    ]
                                }
                            }
                        }
                    }
                }
            ]
        }
    }
}
```
</code></pre></div>
<p dir="auto">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.</p>