{"action":"created","issue":{"url":"https://api.github.com/repos/elasticsearch/kibana/issues/2829","labels_url":"https://api.github.com/repos/elasticsearch/kibana/issues/2829/labels{/name}","comments_url":"https://api.github.com/repos/elasticsearch/kibana/issues/2829/comments","events_url":"https://api.github.com/repos/elasticsearch/kibana/issues/2829/events","html_url":"https://github.com/elasticsearch/kibana/pull/2829","id":56117292,"number":2829,"title":"Bucket on expression","user":{"login":"spenceralger","id":1329312,"avatar_url":"https://avatars.githubusercontent.com/u/1329312?v=3","gravatar_id":"","url":"https://api.github.com/users/spenceralger","html_url":"https://github.com/spenceralger","followers_url":"https://api.github.com/users/spenceralger/followers","following_url":"https://api.github.com/users/spenceralger/following{/other_user}","gists_url":"https://api.github.com/users/spenceralger/gists{/gist_id}","starred_url":"https://api.github.com/users/spenceralger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spenceralger/subscriptions","organizations_url":"https://api.github.com/users/spenceralger/orgs","repos_url":"https://api.github.com/users/spenceralger/repos","events_url":"https://api.github.com/users/spenceralger/events{/privacy}","received_events_url":"https://api.github.com/users/spenceralger/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/elasticsearch/kibana/labels/blocker","name":"blocker","color":"ff0000"},{"url":"https://api.github.com/repos/elasticsearch/kibana/labels/review","name":"review","color":"eb6420"}],"state":"open","locked":false,"assignee":{"login":"lukasolson","id":1178348,"avatar_url":"https://avatars.githubusercontent.com/u/1178348?v=3","gravatar_id":"","url":"https://api.github.com/users/lukasolson","html_url":"https://github.com/lukasolson","followers_url":"https://api.github.com/users/lukasolson/followers","following_url":"https://api.github.com/users/lukasolson/following{/other_user}","gists_url":"https://api.github.com/users/lukasolson/gists{/gist_id}","starred_url":"https://api.github.com/users/lukasolson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lukasolson/subscriptions","organizations_url":"https://api.github.com/users/lukasolson/orgs","repos_url":"https://api.github.com/users/lukasolson/repos","events_url":"https://api.github.com/users/lukasolson/events{/privacy}","received_events_url":"https://api.github.com/users/lukasolson/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/elasticsearch/kibana/milestones/3","labels_url":"https://api.github.com/repos/elasticsearch/kibana/milestones/3/labels","id":815688,"number":3,"title":"4.0.0-RC1","description":"","creator":{"login":"rashidkpc","id":1250387,"avatar_url":"https://avatars.githubusercontent.com/u/1250387?v=3","gravatar_id":"","url":"https://api.github.com/users/rashidkpc","html_url":"https://github.com/rashidkpc","followers_url":"https://api.github.com/users/rashidkpc/followers","following_url":"https://api.github.com/users/rashidkpc/following{/other_user}","gists_url":"https://api.github.com/users/rashidkpc/gists{/gist_id}","starred_url":"https://api.github.com/users/rashidkpc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rashidkpc/subscriptions","organizations_url":"https://api.github.com/users/rashidkpc/orgs","repos_url":"https://api.github.com/users/rashidkpc/repos","events_url":"https://api.github.com/users/rashidkpc/events{/privacy}","received_events_url":"https://api.github.com/users/rashidkpc/received_events","type":"User","site_admin":false},"open_issues":12,"closed_issues":190,"state":"open","created_at":"2014-10-06T19:58:40Z","updated_at":"2015-02-03T20:54:27Z","due_on":null,"closed_at":null},"comments":3,"created_at":"2015-01-31T08:00:23Z","updated_at":"2015-02-03T21:19:10Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/elasticsearch/kibana/pulls/2829","html_url":"https://github.com/elasticsearch/kibana/pull/2829","diff_url":"https://github.com/elasticsearch/kibana/pull/2829.diff","patch_url":"https://github.com/elasticsearch/kibana/pull/2829.patch"},"body":"Closes #2776 and #2772\r\n\r\nThis includes parts of and improvements to (I think) #2820. Improvements have not been merged into the PR yet, but @stormpython and I will work it out.\r\n\r\nAt it's core, this PR moves away from using milliseconds to represent intervals, and incorporates moment.duration objects for this purpose. Doing this means that that we can more accurately calculate the where buckets will be.\r\n\r\nAdditionally, this PR updates the way that we request buckets from elasticsearch. We now ask in the largest possible interval notation (1y, 3.5w, etc). This allows elasticsearch to bucket in the way we would expect. We also are now passing the users timezone offset to elasticsearch. This means that the buckets that come back from elasticsearch will be created using the users perception of time.\r\n\r\nAll of this logic was previously spread across several parts of the app, and now it is all bundled together in the TimeBuckets class. An instance of this class is available at `agg.buckets` on `date_histogram` aggregation configs.\r\n\r\nThe specifics of what this class does is details [in the source](https://github.com/spenceralger/kibana/blob/ad4c2390d787cb5688398fc47d58c33cbc56b665/src/kibana/components/time_buckets/time_buckets.js), but here are the cliffnotes:\r\n\r\n - `TimeBuckets#setBounds(timefilter.getBounds())`:\r\n   - update the internally tracked time bounds.\r\n   - tracking internally provides the exact same results before and after a request is made, rather than re-polling the timefilter as we do today\r\n   - related: `#clearBounds()`, `#hasBounds()`, `#getBounds()` and `#getDuration()`\r\n - `TimeBuckets#setInterval(moment.duration || string || intervalOption)`\r\n   - related: `#getScaledDateFormat()` and `#getInterval()`\r\n - `TimeBuckets#getInterval()`\r\n   - returns a `moment.duration` object that can be used to zero-fill in the vislib and calculate accurate filters\r\n   - decorated with some useful properties:\r\n      - `esValue`, `esUnit`, `expression`, `description`, `scaled`, `scale`\r\n"},"comment":{"url":"https://api.github.com/repos/elasticsearch/kibana/issues/comments/72736945","html_url":"https://github.com/elasticsearch/kibana/pull/2829#issuecomment-72736945","issue_url":"https://api.github.com/repos/elasticsearch/kibana/issues/2829","id":72736945,"user":{"login":"lukasolson","id":1178348,"avatar_url":"https://avatars.githubusercontent.com/u/1178348?v=3","gravatar_id":"","url":"https://api.github.com/users/lukasolson","html_url":"https://github.com/lukasolson","followers_url":"https://api.github.com/users/lukasolson/followers","following_url":"https://api.github.com/users/lukasolson/following{/other_user}","gists_url":"https://api.github.com/users/lukasolson/gists{/gist_id}","starred_url":"https://api.github.com/users/lukasolson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lukasolson/subscriptions","organizations_url":"https://api.github.com/users/lukasolson/orgs","repos_url":"https://api.github.com/users/lukasolson/repos","events_url":"https://api.github.com/users/lukasolson/events{/privacy}","received_events_url":"https://api.github.com/users/lukasolson/received_events","type":"User","site_admin":false},"created_at":"2015-02-03T21:19:10Z","updated_at":"2015-02-03T21:19:10Z","body":"Getting the following error when I select date histogram then change the interval:\r\n\r\n```\r\n TypeError: Cannot read property '_sentToEs' of undefined\r\n    at OptionedAggParam.BucketAggType.params.write (http://localhost:5601/components/agg_types/buckets/date_histogram.js:51:29)\r\n    at http://localhost:5601/components/agg_types/_agg_params.js:61:17\r\n    at AggParams.forEach (native)\r\n    at AggParams.write (http://localhost:5601/components/agg_types/_agg_params.js:59:12)\r\n    at AggConfig.write (http://localhost:5601/components/vis/_agg_config.js:122:31)\r\n    at Parser.functionCall (http://localhost:5601/bower_components/angular/angular.js:10903:21)\r\n    at Scope.$get.Scope.$eval (http://localhost:5601/bower_components/angular/angular.js:12811:28)\r\n    at http://localhost:5601/bower_components/angular/angular.js:18094:13\r\n    at http://localhost:5601/bower_components/angular/angular.js:17872:11\r\n    at forEach (http://localhost:5601/bower_components/angular/angular.js:325:18)\r\n```"}}