{"action":"created","issue":{"url":"https://api.github.com/repos/elastic/elasticsearch/issues/33528","repository_url":"https://api.github.com/repos/elastic/elasticsearch","labels_url":"https://api.github.com/repos/elastic/elasticsearch/issues/33528/labels{/name}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/issues/33528/comments","events_url":"https://api.github.com/repos/elastic/elasticsearch/issues/33528/events","html_url":"https://github.com/elastic/elasticsearch/pull/33528","id":358163699,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE0MDAyOTcy","number":33528,"title":"Unmapped aggs should not run pipelines if they delegate reduction","user":{"login":"polyfractal","id":1224228,"node_id":"MDQ6VXNlcjEyMjQyMjg=","avatar_url":"https://avatars1.githubusercontent.com/u/1224228?v=4","gravatar_id":"","url":"https://api.github.com/users/polyfractal","html_url":"https://github.com/polyfractal","followers_url":"https://api.github.com/users/polyfractal/followers","following_url":"https://api.github.com/users/polyfractal/following{/other_user}","gists_url":"https://api.github.com/users/polyfractal/gists{/gist_id}","starred_url":"https://api.github.com/users/polyfractal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/polyfractal/subscriptions","organizations_url":"https://api.github.com/users/polyfractal/orgs","repos_url":"https://api.github.com/users/polyfractal/repos","events_url":"https://api.github.com/users/polyfractal/events{/privacy}","received_events_url":"https://api.github.com/users/polyfractal/received_events","type":"User","site_admin":false},"labels":[{"id":141141324,"node_id":"MDU6TGFiZWwxNDExNDEzMjQ=","url":"https://api.github.com/repos/elastic/elasticsearch/labels/:Search/Aggregations","name":":Search/Aggregations","color":"0e8a16","default":false},{"id":23173,"node_id":"MDU6TGFiZWwyMzE3Mw==","url":"https://api.github.com/repos/elastic/elasticsearch/labels/%3Ebug","name":">bug","color":"b60205","default":false},{"id":962378555,"node_id":"MDU6TGFiZWw5NjIzNzg1NTU=","url":"https://api.github.com/repos/elastic/elasticsearch/labels/v6.5.0","name":"v6.5.0","color":"Dddddd","default":false},{"id":484855464,"node_id":"MDU6TGFiZWw0ODQ4NTU0NjQ=","url":"https://api.github.com/repos/elastic/elasticsearch/labels/v7.0.0","name":"v7.0.0","color":"dddddd","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-09-07T18:15:35Z","updated_at":"2018-09-13T20:04:01Z","closed_at":null,"author_association":"MEMBER","pull_request":{"url":"https://api.github.com/repos/elastic/elasticsearch/pulls/33528","html_url":"https://github.com/elastic/elasticsearch/pull/33528","diff_url":"https://github.com/elastic/elasticsearch/pull/33528.diff","patch_url":"https://github.com/elastic/elasticsearch/pull/33528.patch"},"body":"`UnmappedTerms`/`UnmappedSampler`/`UnmappedSigTerms` aggs try to delegate reduction to a sibling object that is not unmapped.  That delegated agg will run the reductions, and also reduce any pipeline aggs.  But because delegation comes before running pipelines, the `Unmapped*` agg _also_ tries to run pipeline aggs.\r\n\r\nThis causes the pipeline to run twice, and potentially double it's output in buckets which can create invalid JSON and break when converting to maps.\r\n\r\nThis fixes the issue by toggling a flag in UnmappedTerms if it delegated away reduction so that it knows not to run pipeline aggs either.\r\n\r\nCloses #33514\r\n"},"comment":{"url":"https://api.github.com/repos/elastic/elasticsearch/issues/comments/421134964","html_url":"https://github.com/elastic/elasticsearch/pull/33528#issuecomment-421134964","issue_url":"https://api.github.com/repos/elastic/elasticsearch/issues/33528","id":421134964,"node_id":"MDEyOklzc3VlQ29tbWVudDQyMTEzNDk2NA==","user":{"login":"polyfractal","id":1224228,"node_id":"MDQ6VXNlcjEyMjQyMjg=","avatar_url":"https://avatars1.githubusercontent.com/u/1224228?v=4","gravatar_id":"","url":"https://api.github.com/users/polyfractal","html_url":"https://github.com/polyfractal","followers_url":"https://api.github.com/users/polyfractal/followers","following_url":"https://api.github.com/users/polyfractal/following{/other_user}","gists_url":"https://api.github.com/users/polyfractal/gists{/gist_id}","starred_url":"https://api.github.com/users/polyfractal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/polyfractal/subscriptions","organizations_url":"https://api.github.com/users/polyfractal/orgs","repos_url":"https://api.github.com/users/polyfractal/repos","events_url":"https://api.github.com/users/polyfractal/events{/privacy}","received_events_url":"https://api.github.com/users/polyfractal/received_events","type":"User","site_admin":false},"created_at":"2018-09-13T20:04:01Z","updated_at":"2018-09-13T20:04:01Z","author_association":"MEMBER","body":"@colings86 Ok, reworked to use a sorting approach.  Has an overall smaller change to the codebase, at the small cost of a sort.   I also removed the delegation ability from unmapped aggs, since it's not needed anymore.  If they get called to lead the reduction they will just return themselves, because there are no other mapped aggs.\r\n\r\nThere is a bit of a danger here that the caller won't know to sort first, and won't know that unmapped aggs just return themselves. Right now there's only one place that calls this code so it's reasonably contained.  But we could make the unmapped aggs throw a `UnsupportedOperationException` to avoid accidents.\r\n\r\nThoughts?  "}}
{"actor":{"display_login":"polyfractal"}}