{"action":"created","issue":{"url":"https://api.github.com/repos/elasticsearch/elasticsearch/issues/6405","labels_url":"https://api.github.com/repos/elasticsearch/elasticsearch/issues/6405/labels{/name}","comments_url":"https://api.github.com/repos/elasticsearch/elasticsearch/issues/6405/comments","events_url":"https://api.github.com/repos/elasticsearch/elasticsearch/issues/6405/events","html_url":"https://github.com/elasticsearch/elasticsearch/issues/6405","id":34949727,"number":6405,"title":"date_histogram extendedBounds(DateTime,DateTime) failed when using format option","user":{"login":"dadoonet","id":274222,"avatar_url":"https://avatars.githubusercontent.com/u/274222?v=3","gravatar_id":"","url":"https://api.github.com/users/dadoonet","html_url":"https://github.com/dadoonet","followers_url":"https://api.github.com/users/dadoonet/followers","following_url":"https://api.github.com/users/dadoonet/following{/other_user}","gists_url":"https://api.github.com/users/dadoonet/gists{/gist_id}","starred_url":"https://api.github.com/users/dadoonet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dadoonet/subscriptions","organizations_url":"https://api.github.com/users/dadoonet/orgs","repos_url":"https://api.github.com/users/dadoonet/repos","events_url":"https://api.github.com/users/dadoonet/events{/privacy}","received_events_url":"https://api.github.com/users/dadoonet/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/elasticsearch/elasticsearch/labels/discuss","name":"discuss","color":"fbca04"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2014-06-04T11:16:45Z","updated_at":"2015-02-02T14:15:52Z","closed_at":null,"body":"This code was working in elasticsearch 1.1.1:\r\n\r\n```java\r\nSearchResponse response = esClient.prepareSearch(\"person\")\r\n  .addAggregation(\r\n    AggregationBuilders.dateHistogram(\"by_year\")\r\n      .field(\"dateOfBirth\")\r\n      .minDocCount(0)\r\n      .interval(DateHistogram.Interval.YEAR)\r\n      .extendedBounds(DateTime.parse(\"1940\"), DateTime.parse(\"2009\"))\r\n      .format(\"YYYY\")\r\n  )\r\n  .execute().actionGet();\r\n```\r\n\r\nFrom elasticsearch 1.2.0, it fails with:\r\n\r\n```\r\n[2014-06-04 12:54:38,337][DEBUG][action.search.type       ] [Karla Sofen] [person][0], node[wTCLjroMSk-3LPUx3dIdlA], [P], s[STARTED]: Failed to execute [org.elasticsearch.action.search.SearchRequest@300f4bad] lastShard [true]\r\norg.elasticsearch.ElasticsearchParseException: failed to parse date field [1940-01-01T00:00:00.000Z], tried both date format [YYYY], and timestamp number\r\n\tat org.elasticsearch.common.joda.DateMathParser.parseStringValue(DateMathParser.java:226)\r\n\tat org.elasticsearch.common.joda.DateMathParser.parse(DateMathParser.java:68)\r\n\tat org.elasticsearch.common.joda.DateMathParser.parse(DateMathParser.java:42)\r\n\tat org.elasticsearch.search.aggregations.support.format.ValueParser$DateMath.parseLong(ValueParser.java:96)\r\n\tat org.elasticsearch.search.aggregations.bucket.histogram.ExtendedBounds.processAndValidate(ExtendedBounds.java:52)\r\n\tat org.elasticsearch.search.aggregations.bucket.histogram.HistogramAggregator$Factory.create(HistogramAggregator.java:178)\r\n\tat org.elasticsearch.search.aggregations.bucket.histogram.HistogramAggregator$Factory.create(HistogramAggregator.java:137)\r\n\tat org.elasticsearch.search.aggregations.support.ValuesSourceAggregatorFactory.create(ValuesSourceAggregatorFactory.java:54)\r\n\tat org.elasticsearch.search.aggregations.AggregatorFactories.createAndRegisterContextAware(AggregatorFactories.java:52)\r\n\tat org.elasticsearch.search.aggregations.AggregatorFactories.createTopLevelAggregators(AggregatorFactories.java:145)\r\n\tat org.elasticsearch.search.aggregations.AggregationPhase.preProcess(AggregationPhase.java:79)\r\n\tat org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:99)\r\n\tat org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:257)\r\n\tat org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:206)\r\n\tat org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:203)\r\n\tat org.elasticsearch.search.action.SearchServiceTransportAction$23.run(SearchServiceTransportAction.java:517)\r\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)\r\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)\r\n\tat java.lang.Thread.run(Thread.java:724)\r\nCaused by: java.lang.IllegalArgumentException: Invalid format: \"1940-01-01T00:00:00.000Z\" is malformed at \"-01-01T00:00:00.000Z\"\r\n\tat org.elasticsearch.common.joda.time.format.DateTimeFormatter.parseMillis(DateTimeFormatter.java:754)\r\n\tat org.elasticsearch.common.joda.DateMathParser.parseStringValue(DateMathParser.java:220)\r\n\t... 18 more\r\n```\r\n\r\nOf course, it works nicely when using `extendedBounds(String, String)` instead of `extendedBounds(DateTime, DateTime)`:\r\n\r\n```java\r\nSearchResponse response = esClient.prepareSearch(\"person\")\r\n  .addAggregation(\r\n    AggregationBuilders.dateHistogram(\"by_year\")\r\n      .field(\"dateOfBirth\")\r\n      .minDocCount(0)\r\n      .interval(DateHistogram.Interval.YEAR)\r\n      .extendedBounds(\"1940\", \"2009\")\r\n      .format(\"YYYY\")\r\n  )\r\n  .execute().actionGet();\r\n``` \r\n\r\nAs it was working in 1.1.1, should we consider this as a regression or is it by design?\r\n"},"comment":{"url":"https://api.github.com/repos/elasticsearch/elasticsearch/issues/comments/72463891","html_url":"https://github.com/elasticsearch/elasticsearch/issues/6405#issuecomment-72463891","issue_url":"https://api.github.com/repos/elasticsearch/elasticsearch/issues/6405","id":72463891,"user":{"login":"bakura10","id":1198915,"avatar_url":"https://avatars.githubusercontent.com/u/1198915?v=3","gravatar_id":"","url":"https://api.github.com/users/bakura10","html_url":"https://github.com/bakura10","followers_url":"https://api.github.com/users/bakura10/followers","following_url":"https://api.github.com/users/bakura10/following{/other_user}","gists_url":"https://api.github.com/users/bakura10/gists{/gist_id}","starred_url":"https://api.github.com/users/bakura10/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bakura10/subscriptions","organizations_url":"https://api.github.com/users/bakura10/orgs","repos_url":"https://api.github.com/users/bakura10/repos","events_url":"https://api.github.com/users/bakura10/events{/privacy}","received_events_url":"https://api.github.com/users/bakura10/received_events","type":"User","site_admin":false},"created_at":"2015-02-02T14:15:52Z","updated_at":"2015-02-02T14:15:52Z","body":"I'm having this issue to. Using a timestamp for extended bounds also make the trick."}}