{"action":"created","comment":{"url":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments/50979418","id":50979418,"diff_hunk":"@@ -22,33 +22,52 @@\n import org.elasticsearch.ElasticsearchParseException;\n import org.elasticsearch.common.geo.GeoDistance;\n import org.elasticsearch.common.geo.GeoPoint;\n+import org.elasticsearch.common.geo.GeoUtils;\n+import org.elasticsearch.common.io.stream.NamedWriteable;\n+import org.elasticsearch.common.io.stream.StreamInput;\n+import org.elasticsearch.common.io.stream.StreamOutput;\n import org.elasticsearch.common.unit.DistanceUnit;\n+import org.elasticsearch.common.xcontent.ToXContent;\n import org.elasticsearch.common.xcontent.XContentBuilder;\n+import org.elasticsearch.common.xcontent.XContentParser;\n import org.elasticsearch.index.query.QueryBuilder;\n+import org.elasticsearch.index.query.QueryParseContext;\n+import org.elasticsearch.search.MultiValueMode;\n \n import java.io.IOException;\n import java.util.ArrayList;\n import java.util.Arrays;\n import java.util.List;\n import java.util.Locale;\n+import java.util.Objects;\n \n /**\n  * A geo distance based sorting on a geo point like field.\n  */\n-public class GeoDistanceSortBuilder extends SortBuilder {\n+public class GeoDistanceSortBuilder extends SortBuilder implements ToXContent, NamedWriteable<GeoDistanceSortBuilder>, ParameterParser<GeoDistanceSortBuilder> {\n+    public static final String NAME = \"_geo_distance\";\n+    public static final boolean DEFAULT_COERCE = false;\n+    public static final boolean DEFAULT_IGNORE_MALFORMED = false;\n+    public static final String DEFAULT_SORT_MODE = \"MAX\"; \n+\n+    static final GeoDistanceSortBuilder PROTOTYPE = new GeoDistanceSortBuilder(\"\");\n \n     final String fieldName;\n     private final List<GeoPoint> points = new ArrayList<>();\n-    private final List<String> geohashes = new ArrayList<>();\n \n-    private GeoDistance geoDistance;\n-    private DistanceUnit unit;\n-    private SortOrder order;\n-    private String sortMode;\n+    private GeoDistance geoDistance = GeoDistance.DEFAULT;\n+    private DistanceUnit unit = DistanceUnit.DEFAULT;\n+    private SortOrder order = SortOrder.DEFAULT;\n+    \n+    // TODO there is an enum that covers that parameter which we should be using here\n+    private String sortMode = DEFAULT_SORT_MODE;","path":"core/src/main/java/org/elasticsearch/search/sort/GeoDistanceSortBuilder.java","position":49,"original_position":48,"commit_id":"5e74aec9ac2696281471212226130d5c0f0f117d","original_commit_id":"032b2d194da74be177f7326fea06c62ba2a81387","user":{"login":"MaineC","id":70953,"avatar_url":"https://avatars.githubusercontent.com/u/70953?v=3","gravatar_id":"","url":"https://api.github.com/users/MaineC","html_url":"https://github.com/MaineC","followers_url":"https://api.github.com/users/MaineC/followers","following_url":"https://api.github.com/users/MaineC/following{/other_user}","gists_url":"https://api.github.com/users/MaineC/gists{/gist_id}","starred_url":"https://api.github.com/users/MaineC/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MaineC/subscriptions","organizations_url":"https://api.github.com/users/MaineC/orgs","repos_url":"https://api.github.com/users/MaineC/repos","events_url":"https://api.github.com/users/MaineC/events{/privacy}","received_events_url":"https://api.github.com/users/MaineC/received_events","type":"User","site_admin":false},"body":"Decided to not do any of this validation/setting while parsing xcontent but postpone to build method implementation when discussing f2f","created_at":"2016-01-27T12:55:36Z","updated_at":"2016-01-27T12:55:36Z","html_url":"https://github.com/elastic/elasticsearch/pull/16151#discussion_r50979418","pull_request_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/16151","_links":{"self":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments/50979418"},"html":{"href":"https://github.com/elastic/elasticsearch/pull/16151#discussion_r50979418"},"pull_request":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/16151"}}},"pull_request":{"url":"https://api.github.com/repos/elastic/elasticsearch/pulls/16151","id":56760581,"html_url":"https://github.com/elastic/elasticsearch/pull/16151","diff_url":"https://github.com/elastic/elasticsearch/pull/16151.diff","patch_url":"https://github.com/elastic/elasticsearch/pull/16151.patch","issue_url":"https://api.github.com/repos/elastic/elasticsearch/issues/16151","number":16151,"state":"open","locked":false,"title":"Refactor GeoSortBuilder","user":{"login":"MaineC","id":70953,"avatar_url":"https://avatars.githubusercontent.com/u/70953?v=3","gravatar_id":"","url":"https://api.github.com/users/MaineC","html_url":"https://github.com/MaineC","followers_url":"https://api.github.com/users/MaineC/followers","following_url":"https://api.github.com/users/MaineC/following{/other_user}","gists_url":"https://api.github.com/users/MaineC/gists{/gist_id}","starred_url":"https://api.github.com/users/MaineC/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MaineC/subscriptions","organizations_url":"https://api.github.com/users/MaineC/orgs","repos_url":"https://api.github.com/users/MaineC/repos","events_url":"https://api.github.com/users/MaineC/events{/privacy}","received_events_url":"https://api.github.com/users/MaineC/received_events","type":"User","site_admin":false},"body":"* adds json parsing,\r\n* refactors json serialisation,\r\n* adds writable parsing and serialisation,\r\n* adds json and writable roundtrip test\r\n\r\nThis relates to #15178\r\n\r\nCaveat: Tests are still running locally, so expect changes to fix any failures to come.","created_at":"2016-01-21T15:01:52Z","updated_at":"2016-01-27T12:55:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c727c291c1842417d4082ff61b1fde5c1f4211da","assignee":{"login":"MaineC","id":70953,"avatar_url":"https://avatars.githubusercontent.com/u/70953?v=3","gravatar_id":"","url":"https://api.github.com/users/MaineC","html_url":"https://github.com/MaineC","followers_url":"https://api.github.com/users/MaineC/followers","following_url":"https://api.github.com/users/MaineC/following{/other_user}","gists_url":"https://api.github.com/users/MaineC/gists{/gist_id}","starred_url":"https://api.github.com/users/MaineC/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MaineC/subscriptions","organizations_url":"https://api.github.com/users/MaineC/orgs","repos_url":"https://api.github.com/users/MaineC/repos","events_url":"https://api.github.com/users/MaineC/events{/privacy}","received_events_url":"https://api.github.com/users/MaineC/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/16151/commits","review_comments_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/16151/comments","review_comment_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments{/number}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/issues/16151/comments","statuses_url":"https://api.github.com/repos/elastic/elasticsearch/statuses/5e74aec9ac2696281471212226130d5c0f0f117d","head":{"label":"MaineC:enhancement/15178-sort-geosortbuilder","ref":"enhancement/15178-sort-geosortbuilder","sha":"5e74aec9ac2696281471212226130d5c0f0f117d","user":{"login":"MaineC","id":70953,"avatar_url":"https://avatars.githubusercontent.com/u/70953?v=3","gravatar_id":"","url":"https://api.github.com/users/MaineC","html_url":"https://github.com/MaineC","followers_url":"https://api.github.com/users/MaineC/followers","following_url":"https://api.github.com/users/MaineC/following{/other_user}","gists_url":"https://api.github.com/users/MaineC/gists{/gist_id}","starred_url":"https://api.github.com/users/MaineC/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MaineC/subscriptions","organizations_url":"https://api.github.com/users/MaineC/orgs","repos_url":"https://api.github.com/users/MaineC/repos","events_url":"https://api.github.com/users/MaineC/events{/privacy}","received_events_url":"https://api.github.com/users/MaineC/received_events","type":"User","site_admin":false},"repo":{"id":14859176,"name":"elasticsearch","full_name":"MaineC/elasticsearch","owner":{"login":"MaineC","id":70953,"avatar_url":"https://avatars.githubusercontent.com/u/70953?v=3","gravatar_id":"","url":"https://api.github.com/users/MaineC","html_url":"https://github.com/MaineC","followers_url":"https://api.github.com/users/MaineC/followers","following_url":"https://api.github.com/users/MaineC/following{/other_user}","gists_url":"https://api.github.com/users/MaineC/gists{/gist_id}","starred_url":"https://api.github.com/users/MaineC/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MaineC/subscriptions","organizations_url":"https://api.github.com/users/MaineC/orgs","repos_url":"https://api.github.com/users/MaineC/repos","events_url":"https://api.github.com/users/MaineC/events{/privacy}","received_events_url":"https://api.github.com/users/MaineC/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/MaineC/elasticsearch","description":"Open Source, Distributed, RESTful Search Engine","fork":true,"url":"https://api.github.com/repos/MaineC/elasticsearch","forks_url":"https://api.github.com/repos/MaineC/elasticsearch/forks","keys_url":"https://api.github.com/repos/MaineC/elasticsearch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MaineC/elasticsearch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MaineC/elasticsearch/teams","hooks_url":"https://api.github.com/repos/MaineC/elasticsearch/hooks","issue_events_url":"https://api.github.com/repos/MaineC/elasticsearch/issues/events{/number}","events_url":"https://api.github.com/repos/MaineC/elasticsearch/events","assignees_url":"https://api.github.com/repos/MaineC/elasticsearch/assignees{/user}","branches_url":"https://api.github.com/repos/MaineC/elasticsearch/branches{/branch}","tags_url":"https://api.github.com/repos/MaineC/elasticsearch/tags","blobs_url":"https://api.github.com/repos/MaineC/elasticsearch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MaineC/elasticsearch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MaineC/elasticsearch/git/refs{/sha}","trees_url":"https://api.github.com/repos/MaineC/elasticsearch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MaineC/elasticsearch/statuses/{sha}","languages_url":"https://api.github.com/repos/MaineC/elasticsearch/languages","stargazers_url":"https://api.github.com/repos/MaineC/elasticsearch/stargazers","contributors_url":"https://api.github.com/repos/MaineC/elasticsearch/contributors","subscribers_url":"https://api.github.com/repos/MaineC/elasticsearch/subscribers","subscription_url":"https://api.github.com/repos/MaineC/elasticsearch/subscription","commits_url":"https://api.github.com/repos/MaineC/elasticsearch/commits{/sha}","git_commits_url":"https://api.github.com/repos/MaineC/elasticsearch/git/commits{/sha}","comments_url":"https://api.github.com/repos/MaineC/elasticsearch/comments{/number}","issue_comment_url":"https://api.github.com/repos/MaineC/elasticsearch/issues/comments{/number}","contents_url":"https://api.github.com/repos/MaineC/elasticsearch/contents/{+path}","compare_url":"https://api.github.com/repos/MaineC/elasticsearch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MaineC/elasticsearch/merges","archive_url":"https://api.github.com/repos/MaineC/elasticsearch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MaineC/elasticsearch/downloads","issues_url":"https://api.github.com/repos/MaineC/elasticsearch/issues{/number}","pulls_url":"https://api.github.com/repos/MaineC/elasticsearch/pulls{/number}","milestones_url":"https://api.github.com/repos/MaineC/elasticsearch/milestones{/number}","notifications_url":"https://api.github.com/repos/MaineC/elasticsearch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MaineC/elasticsearch/labels{/name}","releases_url":"https://api.github.com/repos/MaineC/elasticsearch/releases{/id}","deployments_url":"https://api.github.com/repos/MaineC/elasticsearch/deployments","created_at":"2013-12-02T10:17:35Z","updated_at":"2015-05-06T09:43:46Z","pushed_at":"2016-01-27T12:17:00Z","git_url":"git://github.com/MaineC/elasticsearch.git","ssh_url":"git@github.com:MaineC/elasticsearch.git","clone_url":"https://github.com/MaineC/elasticsearch.git","svn_url":"https://github.com/MaineC/elasticsearch","homepage":"http://elasticsearch.org","size":160480,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"elastic:master","ref":"master","sha":"4e5316591a95b28528335e1905558bfa1c0c4c6a","user":{"login":"elastic","id":6764390,"avatar_url":"https://avatars.githubusercontent.com/u/6764390?v=3","gravatar_id":"","url":"https://api.github.com/users/elastic","html_url":"https://github.com/elastic","followers_url":"https://api.github.com/users/elastic/followers","following_url":"https://api.github.com/users/elastic/following{/other_user}","gists_url":"https://api.github.com/users/elastic/gists{/gist_id}","starred_url":"https://api.github.com/users/elastic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elastic/subscriptions","organizations_url":"https://api.github.com/users/elastic/orgs","repos_url":"https://api.github.com/users/elastic/repos","events_url":"https://api.github.com/users/elastic/events{/privacy}","received_events_url":"https://api.github.com/users/elastic/received_events","type":"Organization","site_admin":false},"repo":{"id":507775,"name":"elasticsearch","full_name":"elastic/elasticsearch","owner":{"login":"elastic","id":6764390,"avatar_url":"https://avatars.githubusercontent.com/u/6764390?v=3","gravatar_id":"","url":"https://api.github.com/users/elastic","html_url":"https://github.com/elastic","followers_url":"https://api.github.com/users/elastic/followers","following_url":"https://api.github.com/users/elastic/following{/other_user}","gists_url":"https://api.github.com/users/elastic/gists{/gist_id}","starred_url":"https://api.github.com/users/elastic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elastic/subscriptions","organizations_url":"https://api.github.com/users/elastic/orgs","repos_url":"https://api.github.com/users/elastic/repos","events_url":"https://api.github.com/users/elastic/events{/privacy}","received_events_url":"https://api.github.com/users/elastic/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/elastic/elasticsearch","description":"Open Source, Distributed, RESTful Search Engine","fork":false,"url":"https://api.github.com/repos/elastic/elasticsearch","forks_url":"https://api.github.com/repos/elastic/elasticsearch/forks","keys_url":"https://api.github.com/repos/elastic/elasticsearch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/elastic/elasticsearch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/elastic/elasticsearch/teams","hooks_url":"https://api.github.com/repos/elastic/elasticsearch/hooks","issue_events_url":"https://api.github.com/repos/elastic/elasticsearch/issues/events{/number}","events_url":"https://api.github.com/repos/elastic/elasticsearch/events","assignees_url":"https://api.github.com/repos/elastic/elasticsearch/assignees{/user}","branches_url":"https://api.github.com/repos/elastic/elasticsearch/branches{/branch}","tags_url":"https://api.github.com/repos/elastic/elasticsearch/tags","blobs_url":"https://api.github.com/repos/elastic/elasticsearch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/elastic/elasticsearch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/elastic/elasticsearch/git/refs{/sha}","trees_url":"https://api.github.com/repos/elastic/elasticsearch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/elastic/elasticsearch/statuses/{sha}","languages_url":"https://api.github.com/repos/elastic/elasticsearch/languages","stargazers_url":"https://api.github.com/repos/elastic/elasticsearch/stargazers","contributors_url":"https://api.github.com/repos/elastic/elasticsearch/contributors","subscribers_url":"https://api.github.com/repos/elastic/elasticsearch/subscribers","subscription_url":"https://api.github.com/repos/elastic/elasticsearch/subscription","commits_url":"https://api.github.com/repos/elastic/elasticsearch/commits{/sha}","git_commits_url":"https://api.github.com/repos/elastic/elasticsearch/git/commits{/sha}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/comments{/number}","issue_comment_url":"https://api.github.com/repos/elastic/elasticsearch/issues/comments{/number}","contents_url":"https://api.github.com/repos/elastic/elasticsearch/contents/{+path}","compare_url":"https://api.github.com/repos/elastic/elasticsearch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/elastic/elasticsearch/merges","archive_url":"https://api.github.com/repos/elastic/elasticsearch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/elastic/elasticsearch/downloads","issues_url":"https://api.github.com/repos/elastic/elasticsearch/issues{/number}","pulls_url":"https://api.github.com/repos/elastic/elasticsearch/pulls{/number}","milestones_url":"https://api.github.com/repos/elastic/elasticsearch/milestones{/number}","notifications_url":"https://api.github.com/repos/elastic/elasticsearch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/elastic/elasticsearch/labels{/name}","releases_url":"https://api.github.com/repos/elastic/elasticsearch/releases{/id}","deployments_url":"https://api.github.com/repos/elastic/elasticsearch/deployments","created_at":"2010-02-08T13:20:56Z","updated_at":"2016-01-27T12:44:50Z","pushed_at":"2016-01-27T12:51:13Z","git_url":"git://github.com/elastic/elasticsearch.git","ssh_url":"git@github.com:elastic/elasticsearch.git","clone_url":"https://github.com/elastic/elasticsearch.git","svn_url":"https://github.com/elastic/elasticsearch","homepage":"https://www.elastic.co/products/elasticsearch","size":281368,"stargazers_count":14734,"watchers_count":14734,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":4879,"mirror_url":null,"open_issues_count":1189,"forks":4879,"open_issues":1189,"watchers":14734,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/16151"},"html":{"href":"https://github.com/elastic/elasticsearch/pull/16151"},"issue":{"href":"https://api.github.com/repos/elastic/elasticsearch/issues/16151"},"comments":{"href":"https://api.github.com/repos/elastic/elasticsearch/issues/16151/comments"},"review_comments":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/16151/comments"},"review_comment":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/16151/commits"},"statuses":{"href":"https://api.github.com/repos/elastic/elasticsearch/statuses/5e74aec9ac2696281471212226130d5c0f0f117d"}}}}