{"action":"created","issue":{"url":"https://api.github.com/repos/elastic/kibana/issues/1084","labels_url":"https://api.github.com/repos/elastic/kibana/issues/1084/labels{/name}","comments_url":"https://api.github.com/repos/elastic/kibana/issues/1084/comments","events_url":"https://api.github.com/repos/elastic/kibana/issues/1084/events","html_url":"https://github.com/elastic/kibana/issues/1084","id":29917503,"number":1084,"title":"Nested type aggregations","user":{"login":"Alex-Ikanow","id":851950,"avatar_url":"https://avatars.githubusercontent.com/u/851950?v=3","gravatar_id":"","url":"https://api.github.com/users/Alex-Ikanow","html_url":"https://github.com/Alex-Ikanow","followers_url":"https://api.github.com/users/Alex-Ikanow/followers","following_url":"https://api.github.com/users/Alex-Ikanow/following{/other_user}","gists_url":"https://api.github.com/users/Alex-Ikanow/gists{/gist_id}","starred_url":"https://api.github.com/users/Alex-Ikanow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Alex-Ikanow/subscriptions","organizations_url":"https://api.github.com/users/Alex-Ikanow/orgs","repos_url":"https://api.github.com/users/Alex-Ikanow/repos","events_url":"https://api.github.com/users/Alex-Ikanow/events{/privacy}","received_events_url":"https://api.github.com/users/Alex-Ikanow/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/elastic/kibana/labels/enhancement","name":"enhancement","color":"009800"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":84,"created_at":"2014-03-21T17:10:34Z","updated_at":"2015-07-27T18:27:17Z","closed_at":null,"body":"This is sort of a duplicate of some other issues I searched for but I haven't seen this particular aspect discussed, so I thought this was worth a separate issue.\r\n\r\nYou read the _mapping field, so you should know when a particular field is nested, so can it not automatically apply the correct nested facet/query when such a field is selected in queries or facets? \r\n\r\n(Alternatively/in addition as suggested by #532, you could have a checkbox to allow users to select it themselves, perhaps as an interim measure)\r\n\r\nI'm sure there are some cases where this gets complicated, but there are also a bunch of cases where it's a straightforward changing of one block of JSON to another."},"comment":{"url":"https://api.github.com/repos/elastic/kibana/issues/comments/125296774","html_url":"https://github.com/elastic/kibana/issues/1084#issuecomment-125296774","issue_url":"https://api.github.com/repos/elastic/kibana/issues/1084","id":125296774,"user":{"login":"ppadovani","id":11234684,"avatar_url":"https://avatars.githubusercontent.com/u/11234684?v=3","gravatar_id":"","url":"https://api.github.com/users/ppadovani","html_url":"https://github.com/ppadovani","followers_url":"https://api.github.com/users/ppadovani/followers","following_url":"https://api.github.com/users/ppadovani/following{/other_user}","gists_url":"https://api.github.com/users/ppadovani/gists{/gist_id}","starred_url":"https://api.github.com/users/ppadovani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ppadovani/subscriptions","organizations_url":"https://api.github.com/users/ppadovani/orgs","repos_url":"https://api.github.com/users/ppadovani/repos","events_url":"https://api.github.com/users/ppadovani/events{/privacy}","received_events_url":"https://api.github.com/users/ppadovani/received_events","type":"User","site_admin":false},"created_at":"2015-07-27T18:27:17Z","updated_at":"2015-07-27T18:27:17Z","body":"I decided to look at the kibana 4.1 code .. (I can't use master as it only works with 2.x elastic) .. Please correct me if I'm wrong but it would seem an easy first step to do something along these lines:\r\n\r\n1) Under the 'advanced' collapsible area of an aggregation, add a text field called something like 'nested path'.\r\n2) If the user places a string in that field, then the aggregation this is set on, will have a nested aggregation prepended to it like this:\r\n   \"aggs\":{  \r\n      \"2\":{  \r\n         \"nested\":{ \"path\":\"foo\" },\r\n         \"aggs\":{  \r\n            \"3\":{  \r\n               \"date_histogram\":{  \r\n\r\nTo handle the case of multiple levels of nested objects, you could add a + that allows the user to add additional nested paths. Additionally, to handle the reverse nested, just add a checkbox labeled 'reverse'.\r\n\r\nThis would at least provide limited 'nested' aggregation support.\r\n\r\nFor nested query support, the only solution I can think of short term, would be to allow the user to enter hand coded elastic search json."}}