{"action":"closed","issue":{"url":"https://api.github.com/repos/elastic/elasticsearch/issues/11866","labels_url":"https://api.github.com/repos/elastic/elasticsearch/issues/11866/labels{/name}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/issues/11866/comments","events_url":"https://api.github.com/repos/elastic/elasticsearch/issues/11866/events","html_url":"https://github.com/elastic/elasticsearch/issues/11866","id":90807990,"number":11866,"title":"Terms aggregation does not work with geo bounding box filter","user":{"login":"spencerapplegate","id":1972509,"avatar_url":"https://avatars.githubusercontent.com/u/1972509?v=3","gravatar_id":"","url":"https://api.github.com/users/spencerapplegate","html_url":"https://github.com/spencerapplegate","followers_url":"https://api.github.com/users/spencerapplegate/followers","following_url":"https://api.github.com/users/spencerapplegate/following{/other_user}","gists_url":"https://api.github.com/users/spencerapplegate/gists{/gist_id}","starred_url":"https://api.github.com/users/spencerapplegate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spencerapplegate/subscriptions","organizations_url":"https://api.github.com/users/spencerapplegate/orgs","repos_url":"https://api.github.com/users/spencerapplegate/repos","events_url":"https://api.github.com/users/spencerapplegate/events{/privacy}","received_events_url":"https://api.github.com/users/spencerapplegate/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-06-24T23:46:34Z","updated_at":"2015-06-25T09:03:00Z","closed_at":"2015-06-25T09:03:00Z","body":"I am trying to perform a terms aggregation with the context scoped by a geo_bouding_box filter. The search always returns no buckets in the aggregation when a geo_bouding_box filter is applied to attempt to scope the query to documents in a bounding box.\r\n\r\nI have a `properties` index that have `property` documents with children `listing` documents. Listings have a `broker` attribute. I need to find distinct `broker` attributes and the number of their occurrences for \r\nall properties in a bounding box.\r\n\r\nThe query I am performing is as follows:\r\n```json\r\n{\r\n    \"query\" : {\r\n        \"filtered\": {\r\n            \"query\": { \"match_all\": {} },\r\n            \"filter\": {\r\n                \"geo_bounding_box\" : {\r\n                    \"location\" : {\r\n                        \"top_left\" : {\r\n                            \"lat\" : 40.73,\r\n                            \"lon\" : -74.1\r\n                        },\r\n                        \"bottom_right\" : {\r\n                            \"lat\" : 40.01,\r\n                            \"lon\" : -71.12\r\n                        }\r\n                    }\r\n                }\r\n            }\r\n        }\r\n    },\r\n    \"aggs\" : {\r\n        \"brokers\" : {\r\n            \"terms\" : {\r\n                \"field\" : \"listing.broker\",\r\n                \"order\" : { \"_term\" : \"asc\" }\r\n            }\r\n        }\r\n    }\r\n}\r\n```\r\n\r\nThe result I get back is the following:\r\n```json\r\n{\r\n  \"took\": 6,\r\n  \"timed_out\": false,\r\n  \"_shards\": {\r\n    \"total\": 5,\r\n    \"successful\": 5,\r\n    \"failed\": 0\r\n  },\r\n  \"hits\": {\r\n    \"total\": 2179,\r\n    \"max_score\": 0,\r\n    \"hits\": []\r\n  },\r\n  \"aggregations\": {\r\n    \"brokers\": {\r\n      \"doc_count_error_upper_bound\": 0,\r\n      \"sum_other_doc_count\": 0,\r\n      \"buckets\": []\r\n    }\r\n  }\r\n}\r\n```\r\n\r\nThe mapping of the index is as follows:\r\n```json\r\n{\r\n  \"properties\": {\r\n    \"aliases\": {},\r\n    \"mappings\": {\r\n      \"property\": {\r\n        \"properties\": {\r\n          \"address\": {\r\n            \"type\": \"string\"\r\n          },\r\n          \"city\": {\r\n            \"type\": \"string\"\r\n          },\r\n          \"country\": {\r\n            \"type\": \"string\"\r\n          },\r\n          \"location\": {\r\n            \"type\": \"geo_point\"\r\n          },\r\n          \"id\": {\r\n            \"type\": \"long\"\r\n          },\r\n          \"state\": {\r\n            \"type\": \"string\"\r\n          },\r\n          \"street\": {\r\n            \"type\": \"string\"\r\n          },\r\n          \"title\": {\r\n            \"type\": \"string\"\r\n          },\r\n          \"zip_code\": {\r\n            \"type\": \"string\"\r\n          }\r\n        }\r\n      },\r\n      \"listing\": {\r\n        \"_parent\": {\r\n          \"type\": \"property\"\r\n        },\r\n        \"_routing\": {\r\n          \"required\": true\r\n        },\r\n        \"properties\": {\r\n          \"broker\": {\r\n            \"type\": \"string\",\r\n            \"index\": \"not_analyzed\"\r\n          }\r\n        }\r\n      }\r\n    }\r\n  }\r\n}\r\n```\r\n\r\n**Notes:**\r\n* Replacing the `geo_bounding_box` with other filter types like a `term` filter works as expected\r\n* I am expecting back buckets with the value of the broker attribute on a listing with the document count within the bounding box"}}