{"action":"created","issue":{"url":"https://api.github.com/repos/elastic/elasticsearch/issues/16481","repository_url":"https://api.github.com/repos/elastic/elasticsearch","labels_url":"https://api.github.com/repos/elastic/elasticsearch/issues/16481/labels{/name}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/issues/16481/comments","events_url":"https://api.github.com/repos/elastic/elasticsearch/issues/16481/events","html_url":"https://github.com/elastic/elasticsearch/issues/16481","id":131692313,"number":16481,"title":"geo_distance query, performance issue","user":{"login":"pierrre","id":131535,"avatar_url":"https://avatars.githubusercontent.com/u/131535?v=3","gravatar_id":"","url":"https://api.github.com/users/pierrre","html_url":"https://github.com/pierrre","followers_url":"https://api.github.com/users/pierrre/followers","following_url":"https://api.github.com/users/pierrre/following{/other_user}","gists_url":"https://api.github.com/users/pierrre/gists{/gist_id}","starred_url":"https://api.github.com/users/pierrre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pierrre/subscriptions","organizations_url":"https://api.github.com/users/pierrre/orgs","repos_url":"https://api.github.com/users/pierrre/repos","events_url":"https://api.github.com/users/pierrre/events{/privacy}","received_events_url":"https://api.github.com/users/pierrre/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/elastic/elasticsearch/labels/:Geo","name":":Geo","color":"009800"}],"state":"open","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":10,"created_at":"2016-02-05T16:49:09Z","updated_at":"2016-02-08T13:30:41Z","closed_at":null,"body":"I'm currently migrating from Elasticsearch 1.7 to 2.2 and I have a performance issue with the geo_distance query.\r\n\r\nMy model is simple:\r\n- 20k documents in a type\r\n- each document contains a field with type \"array of object\" (nested mapping)\r\n- these nested documents contains a \"location\" field (lat/lon)\r\n\r\nI want to filter my root documents by distance.\r\n\r\nMy search queries:\r\n\r\nElasticsearch 1.7:\r\n```json\r\n{\r\n \"filter\": {\r\n   \"geo_distance\": {\r\n     \"distance\": \"100000m\",\r\n     \"stores.location\": {\r\n       \"lat\": 48.86,\r\n       \"lon\": \"2.35\"\r\n     }\r\n   }\r\n }\r\n}\r\n```\r\n\r\nElasticsearch 2.2:\r\n```json\r\n{\r\n  \"query\": {\r\n    \"bool\": {\r\n      \"filter\": {\r\n        \"geo_distance\": {\r\n          \"distance\": \"100000m\",\r\n          \"stores.location\": {\r\n            \"lat\": 48.86,\r\n            \"lon\": 2.35\r\n          }\r\n        }\r\n      }\r\n    }\r\n  }\r\n}\r\n```\r\n\r\nWith Elasticsearch 1.7, the response time (took) is around 35ms.\r\nWith Elasticsearch 2.2, the response time is around 3700ms.\r\n\r\nIf I test with random locations, the response time of Elasticsearch 1.7 stay stable. (there is no cached result)\r\n\r\nIs there a way to improve performance?"},"comment":{"url":"https://api.github.com/repos/elastic/elasticsearch/issues/comments/181367609","html_url":"https://github.com/elastic/elasticsearch/issues/16481#issuecomment-181367609","issue_url":"https://api.github.com/repos/elastic/elasticsearch/issues/16481","id":181367609,"user":{"login":"pierrre","id":131535,"avatar_url":"https://avatars.githubusercontent.com/u/131535?v=3","gravatar_id":"","url":"https://api.github.com/users/pierrre","html_url":"https://github.com/pierrre","followers_url":"https://api.github.com/users/pierrre/followers","following_url":"https://api.github.com/users/pierrre/following{/other_user}","gists_url":"https://api.github.com/users/pierrre/gists{/gist_id}","starred_url":"https://api.github.com/users/pierrre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pierrre/subscriptions","organizations_url":"https://api.github.com/users/pierrre/orgs","repos_url":"https://api.github.com/users/pierrre/repos","events_url":"https://api.github.com/users/pierrre/events{/privacy}","received_events_url":"https://api.github.com/users/pierrre/received_events","type":"User","site_admin":false},"created_at":"2016-02-08T13:30:40Z","updated_at":"2016-02-08T13:30:40Z","body":"> is it the total number of documents with a field named stores.location ?\r\n\r\n@jimferenczi yes, there are 20k root documents with the field `stores.location`.\r\nThere are between 50-200 documents in each `stores`fields. (sometimes more)\r\n\r\n> Do you have other types with the same field name in your index ?\r\n\r\nNo, there is only 1 type that uses `stores` & `stores.location` (in the mapping).\r\nI checked with GET `myindex/_mapping`.\r\n\r\n> What is the total number of documents in this index (20k ?) ?\r\n\r\nGET `myindex/_count` returns 207322."}}