{"action":"opened","issue":{"url":"https://api.github.com/repos/searchbox-io/Jest/issues/187","labels_url":"https://api.github.com/repos/searchbox-io/Jest/issues/187/labels{/name}","comments_url":"https://api.github.com/repos/searchbox-io/Jest/issues/187/comments","events_url":"https://api.github.com/repos/searchbox-io/Jest/issues/187/events","html_url":"https://github.com/searchbox-io/Jest/issues/187","id":60676496,"number":187,"title":"Sub-aggregations available at the wrong level for bucketing aggregations","user":{"login":"cfstout","id":4613410,"avatar_url":"https://avatars.githubusercontent.com/u/4613410?v=3","gravatar_id":"","url":"https://api.github.com/users/cfstout","html_url":"https://github.com/cfstout","followers_url":"https://api.github.com/users/cfstout/followers","following_url":"https://api.github.com/users/cfstout/following{/other_user}","gists_url":"https://api.github.com/users/cfstout/gists{/gist_id}","starred_url":"https://api.github.com/users/cfstout/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cfstout/subscriptions","organizations_url":"https://api.github.com/users/cfstout/orgs","repos_url":"https://api.github.com/users/cfstout/repos","events_url":"https://api.github.com/users/cfstout/events{/privacy}","received_events_url":"https://api.github.com/users/cfstout/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-03-11T15:29:06Z","updated_at":"2015-03-11T15:29:06Z","closed_at":null,"body":"I just realized that the implementation of Aggregations is not entirely correct. All bucketing aggregations:\r\n```\r\nFilterAggregation\r\nGeohashGridAggregation\r\nHistogramAggregation\r\nDateHistogramAggregation\r\nMissingAggregation\r\nRangeAggregation\r\nIpv4RangeAggregation\r\nDateRangeAggregation\r\nGeoDistanceAggregation\r\nSignificantTermsAggregation\r\nTermsAggregation\r\n```\r\nShould have sub aggregations available from the buckets they return as opposed to their specific aggregation root. I think we can fix by having each of these aggregations have a shared abstract Bucket object that each of their internal structures extends. Then bucket could be an extension of Aggregation, storing the json root of the bucket which would give access to sub-aggregations.\r\n"}}