{"action":"closed","issue":{"url":"https://api.github.com/repos/elastic/elasticsearch/issues/19166","repository_url":"https://api.github.com/repos/elastic/elasticsearch","labels_url":"https://api.github.com/repos/elastic/elasticsearch/issues/19166/labels{/name}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/issues/19166/comments","events_url":"https://api.github.com/repos/elastic/elasticsearch/issues/19166/events","html_url":"https://github.com/elastic/elasticsearch/issues/19166","id":163025958,"number":19166,"title":"Get all parents if ALL/NONE of children match","user":{"login":"jondeandres","id":122581,"avatar_url":"https://avatars.githubusercontent.com/u/122581?v=3","gravatar_id":"","url":"https://api.github.com/users/jondeandres","html_url":"https://github.com/jondeandres","followers_url":"https://api.github.com/users/jondeandres/followers","following_url":"https://api.github.com/users/jondeandres/following{/other_user}","gists_url":"https://api.github.com/users/jondeandres/gists{/gist_id}","starred_url":"https://api.github.com/users/jondeandres/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jondeandres/subscriptions","organizations_url":"https://api.github.com/users/jondeandres/orgs","repos_url":"https://api.github.com/users/jondeandres/repos","events_url":"https://api.github.com/users/jondeandres/events{/privacy}","received_events_url":"https://api.github.com/users/jondeandres/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-06-29T21:03:19Z","updated_at":"2016-06-30T12:11:43Z","closed_at":"2016-06-30T12:11:43Z","body":"Hi, I'm not sure I can do this with ES:\r\n\r\nHaving a parent doc_type A and children doc_type B. Is there a way to query \"all the A documents where NONE/ALL of their Bs children match some filters\"?\r\n\r\nHaving:\r\n\r\n- A1\r\n  - B1.foo = 200\r\n  - B2.foo = 100\r\n- A2\r\n  - B3. foo = 100\r\n\r\nI tried with the query below, but with this I get A1 since one of their children doesn't have `foo: 100`.\r\n```json\r\n{\r\n  \"query\": {\r\n    \"has_child\": {\r\n      \"type\": \"b\",\r\n      \"query\": {\r\n        \"filtered\": {\r\n          \"filter\": {\r\n            \"bool\": {\r\n              \"must_not\": { \"term\": { \"foo\": 100 }}\r\n            }\r\n          }\r\n        }\r\n      }\r\n    }\r\n  }\r\n}\r\n```\r\n\r\nIn summary, can we get parents for those which *all*/*none* of their children match the given filters?\r\n"}}
{"actor":{"display_login":"clintongormley"}}