{"action":"closed","issue":{"url":"https://api.github.com/repos/elastic/elasticsearch/issues/9716","labels_url":"https://api.github.com/repos/elastic/elasticsearch/issues/9716/labels{/name}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/issues/9716/comments","events_url":"https://api.github.com/repos/elastic/elasticsearch/issues/9716/events","html_url":"https://github.com/elastic/elasticsearch/issues/9716","id":57898426,"number":9716,"title":"Geoshape query returns incorrect results","user":{"login":"j0r0","id":370737,"avatar_url":"https://avatars.githubusercontent.com/u/370737?v=3","gravatar_id":"","url":"https://api.github.com/users/j0r0","html_url":"https://github.com/j0r0","followers_url":"https://api.github.com/users/j0r0/followers","following_url":"https://api.github.com/users/j0r0/following{/other_user}","gists_url":"https://api.github.com/users/j0r0/gists{/gist_id}","starred_url":"https://api.github.com/users/j0r0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/j0r0/subscriptions","organizations_url":"https://api.github.com/users/j0r0/orgs","repos_url":"https://api.github.com/users/j0r0/repos","events_url":"https://api.github.com/users/j0r0/events{/privacy}","received_events_url":"https://api.github.com/users/j0r0/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/elastic/elasticsearch/labels/:Geo","name":":Geo","color":"009800"},{"url":"https://api.github.com/repos/elastic/elasticsearch/labels/feedback_needed","name":"feedback_needed","color":"d4c5f9"}],"state":"closed","locked":false,"assignee":{"login":"nknize","id":830187,"avatar_url":"https://avatars.githubusercontent.com/u/830187?v=3","gravatar_id":"","url":"https://api.github.com/users/nknize","html_url":"https://github.com/nknize","followers_url":"https://api.github.com/users/nknize/followers","following_url":"https://api.github.com/users/nknize/following{/other_user}","gists_url":"https://api.github.com/users/nknize/gists{/gist_id}","starred_url":"https://api.github.com/users/nknize/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nknize/subscriptions","organizations_url":"https://api.github.com/users/nknize/orgs","repos_url":"https://api.github.com/users/nknize/repos","events_url":"https://api.github.com/users/nknize/events{/privacy}","received_events_url":"https://api.github.com/users/nknize/received_events","type":"User","site_admin":false},"milestone":null,"comments":7,"created_at":"2015-02-17T08:56:17Z","updated_at":"2015-04-14T13:20:50Z","closed_at":"2015-04-14T13:20:50Z","body":"With version 1.4.1 we had this issue: #8467\r\nhttps://github.com/elasticsearch/elasticsearch/issues/8467\r\n\r\nWith 1.4.1 the workaround returns completely wrong results.\r\nExample;\r\n```\r\n{\r\n  \"size\" : 0,\r\n  \"query\" : {\r\n    \"bool\" : {\r\n      \"must\" : [ {\r\n        \"range\" : {\r\n          \"ts\" : {\r\n            \"from\" : \"2015-02-13T00:00:00.0Z\",\r\n            \"to\" : \"2015-02-13T23:59:58.0Z\",\r\n            \"include_lower\" : true,\r\n            \"include_upper\" : true\r\n          }\r\n        }\r\n      }, {\r\n        \"geo_shape\" : {\r\n          \"loc\" : {\r\n            \"shape\" : {\r\n              \"type\" : \"polygon\",\r\n              \"coordinates\" : [ [ [ -179.999, 89.999 ], [ 179.999, 89.999 ], [ 179.999, -89.999 ], [ -179.999, -89.999 ], [ -179.999, 89.999 ] ] ]\r\n            },\r\n            \"relation\": \"within\"\r\n          }\r\n        }\r\n      } ]\r\n    }\r\n  }\r\n}\r\n```\r\n\r\nThis returns 4360 results, which is clearly wrong.\r\n\r\nAnother query (only polygon changed a bit)\r\n```\r\nGET track_201502/_search\r\n{\r\n  \"query\": {\r\n    \"bool\": {\r\n      \"must\": [\r\n        {\r\n          \"geo_shape\": {\r\n      \"loc\": {\r\n        \"shape\": {\r\n          \"type\": \"polygon\",\r\n          \"coordinates\": [[[-180,90],[180,90],[180,-90],[-180,-90],[-180,90]]]\r\n        },\r\n        \"relation\": \"within\"\r\n      }\r\n    }\r\n        },\r\n        {\r\n          \"range\": {\r\n            \"ts\": {\r\n              \"from\" : \"2015-02-13T00:00:00.0Z\",\r\n            \"to\" : \"2015-02-13T23:59:58.0Z\",\r\n            \"include_lower\" : true,\r\n            \"include_upper\" : true\r\n            }\r\n          }\r\n        }\r\n      ]\r\n    }\r\n  }\r\n  ,\r\n  \"size\": 0\r\n}\r\n```\r\nThis returns 6678451 results which is more likely .\r\nAs you can see the only difference between the 2 queries is the polygon .\r\nInstead of 180/90 we have 179.999/89.999\r\nThis was workaround for  #8467"}}