{"action":"opened","issue":{"url":"https://api.github.com/repos/elastic/elasticsearch/issues/25648","repository_url":"https://api.github.com/repos/elastic/elasticsearch","labels_url":"https://api.github.com/repos/elastic/elasticsearch/issues/25648/labels{/name}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/issues/25648/comments","events_url":"https://api.github.com/repos/elastic/elasticsearch/issues/25648/events","html_url":"https://github.com/elastic/elasticsearch/issues/25648","id":242059997,"number":25648,"title":"DateHistogramAggregationBuilder#toString yields unexpected error string","user":{"login":"yuthura","id":608953,"avatar_url":"https://avatars2.githubusercontent.com/u/608953?v=3","gravatar_id":"","url":"https://api.github.com/users/yuthura","html_url":"https://github.com/yuthura","followers_url":"https://api.github.com/users/yuthura/followers","following_url":"https://api.github.com/users/yuthura/following{/other_user}","gists_url":"https://api.github.com/users/yuthura/gists{/gist_id}","starred_url":"https://api.github.com/users/yuthura/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yuthura/subscriptions","organizations_url":"https://api.github.com/users/yuthura/orgs","repos_url":"https://api.github.com/users/yuthura/repos","events_url":"https://api.github.com/users/yuthura/events{/privacy}","received_events_url":"https://api.github.com/users/yuthura/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-07-11T14:05:04Z","updated_at":"2017-07-11T14:05:04Z","closed_at":null,"body":"**Elasticsearch version**: 5.3.2\r\n\r\n**Plugins installed**: []\r\n\r\n**JVM version**: 1.8.0_121\r\n\r\n**OS version**: Windows 10\r\n\r\n**Description of the problem including expected versus actual behavior**:\r\n\r\nUsing `toString()` on a `DateHistogramAggregationBuilder` (and most likely other aggregation builders as well) yields the following result:\r\n```\r\n{ \"error\" : \"JsonGenerationException[Can not write a field name, expecting a value]\"}\r\n```\r\n\r\nExpected result is something along the lines of:\r\n```\r\n{ \"my_aggr\" : { \"date_histogram\" : { ... } } }\r\n```\r\n\r\n\r\n**Steps to reproduce**:\r\n\r\nRun the following class:\r\n```\r\nimport org.elasticsearch.search.aggregations.AggregationBuilders;\r\nimport org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramInterval;\r\nimport org.elasticsearch.search.aggregations.bucket.histogram.Histogram;\r\n\r\npublic class Test {\r\n    public static void main(String[] args) {\r\n        System.out.println(\r\n            AggregationBuilders.dateHistogram(\"revenueHistogram\")\r\n        );\r\n    }\r\n}\r\n```\r\n\r\nThis is a follow-up on an existing (closed) issue for the following pull request (as request by @cbuescher ): #22280\r\n"}}
{"actor":{"display_login":"yuthura"}}