{"action":"created","issue":{"url":"https://api.github.com/repos/olivere/elastic/issues/311","repository_url":"https://api.github.com/repos/olivere/elastic","labels_url":"https://api.github.com/repos/olivere/elastic/issues/311/labels{/name}","comments_url":"https://api.github.com/repos/olivere/elastic/issues/311/comments","events_url":"https://api.github.com/repos/olivere/elastic/issues/311/events","html_url":"https://github.com/olivere/elastic/issues/311","id":161861710,"number":311,"title":"UnmarshalJSON of AggregationValueMetric should return error if required fields are missing","user":{"login":"Jack47","id":1720972,"avatar_url":"https://avatars.githubusercontent.com/u/1720972?v=3","gravatar_id":"","url":"https://api.github.com/users/Jack47","html_url":"https://github.com/Jack47","followers_url":"https://api.github.com/users/Jack47/followers","following_url":"https://api.github.com/users/Jack47/following{/other_user}","gists_url":"https://api.github.com/users/Jack47/gists{/gist_id}","starred_url":"https://api.github.com/users/Jack47/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Jack47/subscriptions","organizations_url":"https://api.github.com/users/Jack47/orgs","repos_url":"https://api.github.com/users/Jack47/repos","events_url":"https://api.github.com/users/Jack47/events{/privacy}","received_events_url":"https://api.github.com/users/Jack47/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2016-06-23T07:56:47Z","updated_at":"2016-06-26T23:22:27Z","closed_at":null,"body":"\r\n### Which version of Elastic are you using?\r\n\r\n[ ] elastic.v2 (for Elasticsearch 1.x)\r\n[X] elastic.v3 (for Elasticsearch 2.x)\r\n\r\n### Please describe the expected behavior\r\nUnmarshalJSON of struct `AggrationValueMetric`, `AggregationPercentilesMetric` should return error if the required fields are missing\r\n\r\n### Please describe the actual behavior\r\nUnmarshalJSON of struct `AggrationValueMetric` will success even if the `value` field is missing.\r\n\r\nPS: I'm using the `SearchService.Source()` to set the request body manually, I need to parse the response's `SearchResult` manually, so I use `UnmarshalJSON` to guess the returned aggregation type and encountered this problem.  \r\n\r\n"},"comment":{"url":"https://api.github.com/repos/olivere/elastic/issues/comments/228629396","html_url":"https://github.com/olivere/elastic/issues/311#issuecomment-228629396","issue_url":"https://api.github.com/repos/olivere/elastic/issues/311","id":228629396,"user":{"login":"Jack47","id":1720972,"avatar_url":"https://avatars.githubusercontent.com/u/1720972?v=3","gravatar_id":"","url":"https://api.github.com/users/Jack47","html_url":"https://github.com/Jack47","followers_url":"https://api.github.com/users/Jack47/followers","following_url":"https://api.github.com/users/Jack47/following{/other_user}","gists_url":"https://api.github.com/users/Jack47/gists{/gist_id}","starred_url":"https://api.github.com/users/Jack47/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Jack47/subscriptions","organizations_url":"https://api.github.com/users/Jack47/orgs","repos_url":"https://api.github.com/users/Jack47/repos","events_url":"https://api.github.com/users/Jack47/events{/privacy}","received_events_url":"https://api.github.com/users/Jack47/received_events","type":"User","site_admin":false},"created_at":"2016-06-26T23:22:27Z","updated_at":"2016-06-26T23:22:27Z","body":" I'm using elastic query DSL directly, it will save me from calling various elastic go client interface. I use the `SearchService.Source()` to set the DSL I received, the DSL is guaranteed to use Value or Percentile aggregation. I need to parse the response's `SearchResult` manually, so I use `UnmarshalJSON` to guess the returned aggregation type is whether `AggregationPercentilesMetric`  or `AggregationValueMetric`. Is there a better way to do this ?"}}
{"actor":{"display_login":"Jack47"}}