{"action":"created","issue":{"url":"https://api.github.com/repos/elastic/elasticsearch/issues/29079","repository_url":"https://api.github.com/repos/elastic/elasticsearch","labels_url":"https://api.github.com/repos/elastic/elasticsearch/issues/29079/labels{/name}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/issues/29079/comments","events_url":"https://api.github.com/repos/elastic/elasticsearch/issues/29079/events","html_url":"https://github.com/elastic/elasticsearch/issues/29079","id":305433925,"number":29079,"title":"Composite aggregation doesn't allow filter aggregation","user":{"login":"seanziee","id":23384471,"avatar_url":"https://avatars0.githubusercontent.com/u/23384471?v=4","gravatar_id":"","url":"https://api.github.com/users/seanziee","html_url":"https://github.com/seanziee","followers_url":"https://api.github.com/users/seanziee/followers","following_url":"https://api.github.com/users/seanziee/following{/other_user}","gists_url":"https://api.github.com/users/seanziee/gists{/gist_id}","starred_url":"https://api.github.com/users/seanziee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seanziee/subscriptions","organizations_url":"https://api.github.com/users/seanziee/orgs","repos_url":"https://api.github.com/users/seanziee/repos","events_url":"https://api.github.com/users/seanziee/events{/privacy}","received_events_url":"https://api.github.com/users/seanziee/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-03-15T06:49:40Z","updated_at":"2018-03-15T09:59:40Z","closed_at":null,"author_association":"NONE","body":"<!--\r\n\r\n** Please read the guidelines below. **\r\n\r\nIssues that do not follow these guidelines are likely to be closed.\r\n\r\n1.  GitHub is reserved for bug reports and feature requests. The best place to\r\n    ask a general question is at the Elastic [forums](https://discuss.elastic.co).\r\n    GitHub is not the place for general questions.\r\n\r\n2.  Is this bug report or feature request for a supported OS? If not, it\r\n    is likely to be closed.  See https://www.elastic.co/support/matrix#show_os\r\n\r\n3.  Please fill out EITHER the feature request block or the bug report block\r\n    below, and delete the other block.\r\n\r\n-->\r\n<!-- Bug report -->\r\n\r\n**Elasticsearch version** (`bin/elasticsearch --version`): 6.2.2\r\n\r\nI'd like to define a filters under the composite aggregation but it seems not allowed. Why not? I could really use it!\r\n\r\nWhich aggregations are allowed under the composite agg?\r\n\r\n```\r\nGET */_search\r\n{\r\n  \"size\": 0,\r\n  \"aggs\": {\r\n    \"data\": {\r\n      \"composite\": {\r\n        \"size\": 100,\r\n        \"sources\": [\r\n          {\r\n            \"personname\": {\r\n              \"terms\": {\r\n                \"field\": \"personname.keyword\"\r\n              }\r\n            }\r\n          },\r\n          {\r\n            \"test\": {\r\n              \"filters\": {\r\n                \"filters\": {\r\n                  \"query\": {\r\n                    \"query_string\": {\r\n                      \"query\": \"all\"\r\n                    }\r\n                  }\r\n                }\r\n              }\r\n            }\r\n          }\r\n        ]\r\n      }\r\n    }\r\n  }\r\n}\r\n```\r\nError:\r\n\r\n```\r\n{\r\n  \"error\": {\r\n    \"root_cause\": [\r\n      {\r\n        \"type\": \"parsing_exception\",\r\n        \"reason\": \"invalid source type: filters\",\r\n        \"line\": 17,\r\n        \"col\": 26\r\n      }\r\n    ],\r\n    \"type\": \"parsing_exception\",\r\n    \"reason\": \"[composite] failed to parse field [sources]\",\r\n    \"line\": 17,\r\n    \"col\": 26,\r\n    \"caused_by\": {\r\n      \"type\": \"parsing_exception\",\r\n      \"reason\": \"invalid source type: filters\",\r\n      \"line\": 17,\r\n      \"col\": 26\r\n    }\r\n  },\r\n  \"status\": 400\r\n}\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/elastic/elasticsearch/issues/comments/373322133","html_url":"https://github.com/elastic/elasticsearch/issues/29079#issuecomment-373322133","issue_url":"https://api.github.com/repos/elastic/elasticsearch/issues/29079","id":373322133,"user":{"login":"colings86","id":236731,"avatar_url":"https://avatars0.githubusercontent.com/u/236731?v=4","gravatar_id":"","url":"https://api.github.com/users/colings86","html_url":"https://github.com/colings86","followers_url":"https://api.github.com/users/colings86/followers","following_url":"https://api.github.com/users/colings86/following{/other_user}","gists_url":"https://api.github.com/users/colings86/gists{/gist_id}","starred_url":"https://api.github.com/users/colings86/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/colings86/subscriptions","organizations_url":"https://api.github.com/users/colings86/orgs","repos_url":"https://api.github.com/users/colings86/repos","events_url":"https://api.github.com/users/colings86/events{/privacy}","received_events_url":"https://api.github.com/users/colings86/received_events","type":"User","site_admin":false},"created_at":"2018-03-15T09:59:40Z","updated_at":"2018-03-15T09:59:40Z","author_association":"MEMBER","body":"You can't add the `filters` aggregation as a `source` in the `composite` aggregation as it only accepts `term`, `histogram` and `date_histogram` sources. However you can have a `filters` aggregation as a sub-aggregation as below:\r\n```\r\nGET */_search\r\n{\r\n  \"size\": 0,\r\n  \"aggs\": {\r\n    \"data\": {\r\n      \"composite\": {\r\n        \"size\": 100,\r\n        \"sources\": [\r\n          {\r\n            \"personname\": {\r\n              \"terms\": {\r\n                \"field\": \"personname.keyword\"\r\n              }\r\n            }\r\n          }\r\n        ]\r\n      },\r\n      \"aggs\": {\r\n        \"test\": {\r\n          \"filters\": {\r\n            \"filters\": {\r\n              \"query\": {\r\n                \"query_string\": {\r\n                  \"query\": \"all\"\r\n                }\r\n              }\r\n            }\r\n          }\r\n        }\r\n      }\r\n    }\r\n  }\r\n}\r\n```\r\nThis means that although the `filters` aggregation is not involved in selecting the \"page\" for the aggregation it will still be returned for every bucket of the `composite` aggregation.\r\n\r\nDoes this work for your use-case?"}}
{"actor":{"display_login":"colings86"}}