{"action":"created","issue":{"url":"https://api.github.com/repos/elastic/elasticsearch/issues/10481","labels_url":"https://api.github.com/repos/elastic/elasticsearch/issues/10481/labels{/name}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/issues/10481/comments","events_url":"https://api.github.com/repos/elastic/elasticsearch/issues/10481/events","html_url":"https://github.com/elastic/elasticsearch/issues/10481","id":67113638,"number":10481,"title":"has_child applied on an alias does not work","user":{"login":"mikiot","id":9550541,"avatar_url":"https://avatars.githubusercontent.com/u/9550541?v=3","gravatar_id":"","url":"https://api.github.com/users/mikiot","html_url":"https://github.com/mikiot","followers_url":"https://api.github.com/users/mikiot/followers","following_url":"https://api.github.com/users/mikiot/following{/other_user}","gists_url":"https://api.github.com/users/mikiot/gists{/gist_id}","starred_url":"https://api.github.com/users/mikiot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikiot/subscriptions","organizations_url":"https://api.github.com/users/mikiot/orgs","repos_url":"https://api.github.com/users/mikiot/repos","events_url":"https://api.github.com/users/mikiot/events{/privacy}","received_events_url":"https://api.github.com/users/mikiot/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-04-08T12:02:16Z","updated_at":"2015-04-08T12:31:03Z","closed_at":"2015-04-08T12:31:03Z","body":"I am using elasticsearch 1.5.0 and I have a filtered alias.\r\nThe index contains 2 types A and B. B is a child to A. The filter extracts from the index all the types applying some conditions. B gets soft deleted (marked as deleted in the document with a flag) and does not show in the documents returned when searching the alias. But when I query for A that do not have B (using a has_child filter), all A are returned regardless if they any children in the alias (they still have children in the index).\r\n\r\nThis is a workaround for this issue https://github.com/elastic/elasticsearch/issues/10135. I removed the has_child filter for the alias (see person in the issue ) tried to filter on search time with this simple filter:\r\n\r\n``` \r\n{\"filter\":{\"has_child\":{\"type\":\"message\",\"filter\":{\"match_all\":{}},\"min_children\":1}}}\r\n```\r\nAlso I think that the children aggregation is affected in this scenario as any aggregation on A will take into consideration the deleted B.\r\n\r\nIs this a bug?"},"comment":{"url":"https://api.github.com/repos/elastic/elasticsearch/issues/comments/90900236","html_url":"https://github.com/elastic/elasticsearch/issues/10481#issuecomment-90900236","issue_url":"https://api.github.com/repos/elastic/elasticsearch/issues/10481","id":90900236,"user":{"login":"clintongormley","id":56599,"avatar_url":"https://avatars.githubusercontent.com/u/56599?v=3","gravatar_id":"","url":"https://api.github.com/users/clintongormley","html_url":"https://github.com/clintongormley","followers_url":"https://api.github.com/users/clintongormley/followers","following_url":"https://api.github.com/users/clintongormley/following{/other_user}","gists_url":"https://api.github.com/users/clintongormley/gists{/gist_id}","starred_url":"https://api.github.com/users/clintongormley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clintongormley/subscriptions","organizations_url":"https://api.github.com/users/clintongormley/orgs","repos_url":"https://api.github.com/users/clintongormley/repos","events_url":"https://api.github.com/users/clintongormley/events{/privacy}","received_events_url":"https://api.github.com/users/clintongormley/received_events","type":"User","site_admin":false},"created_at":"2015-04-08T12:31:03Z","updated_at":"2015-04-08T12:31:03Z","body":"Hi @mikiot \r\n\r\nThe `filter` (now renamed to `post_filter`) is only applied after aggregations are calculated.  This is not a bug, it is by design.  You would need to include the `has_child` clause in your main `query` for it to be applied where you want it."}}