{"action":"created","comment":{"url":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments/91271119","pull_request_review_id":11778544,"id":91271119,"diff_hunk":"@@ -0,0 +1,131 @@\n+/*\n+ * Licensed to Elasticsearch under one or more contributor\n+ * license agreements. See the NOTICE file distributed with\n+ * this work for additional information regarding copyright\n+ * ownership. Elasticsearch licenses this file to you under\n+ * the Apache License, Version 2.0 (the \"License\"); you may\n+ * not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ *    http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing,\n+ * software distributed under the License is distributed on an\n+ * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+ * KIND, either express or implied.  See the License for the\n+ * specific language governing permissions and limitations\n+ * under the License.\n+ */\n+\n+package org.elasticsearch.search.fetch.subphase.highlight;\n+\n+import org.elasticsearch.common.ParsingException;\n+import org.elasticsearch.common.io.stream.BytesStreamOutput;\n+import org.elasticsearch.common.io.stream.StreamInput;\n+import org.elasticsearch.common.text.Text;\n+import org.elasticsearch.common.xcontent.ToXContent;\n+import org.elasticsearch.common.xcontent.XContentBuilder;\n+import org.elasticsearch.common.xcontent.XContentFactory;\n+import org.elasticsearch.common.xcontent.XContentParser;\n+import org.elasticsearch.common.xcontent.XContentType;\n+import org.elasticsearch.test.ESTestCase;\n+\n+import java.io.IOException;\n+import java.util.Arrays;\n+\n+import static org.elasticsearch.test.EqualsHashCodeTestUtils.checkEqualsAndHashCode;\n+\n+public class HighlightFieldTests extends ESTestCase {\n+\n+    public HighlightField createTestItem() {\n+        String name = frequently() ? randomAsciiOfLengthBetween(1, 20) : randomRealisticUnicodeOfCodepointLengthBetween(1, 20);\n+        Text[] fragments = null;\n+        if (frequently()) {\n+            int size = randomIntBetween(0, 5);\n+            fragments = new Text[size];\n+            for (int i = 0; i < size; i++) {\n+                fragments[i] = new Text(\n+                        frequently() ? randomAsciiOfLengthBetween(10, 30) : randomRealisticUnicodeOfCodepointLengthBetween(10, 30));\n+            }\n+        }\n+        return new HighlightField(name, fragments);\n+    }\n+\n+    public void testFromXContent() throws IOException {\n+        HighlightField highlightField = createTestItem();\n+        XContentBuilder builder = XContentFactory.contentBuilder(randomFrom(XContentType.values()));\n+        if (randomBoolean()) {\n+            builder.prettyPrint();\n+        }\n+        builder.startObject();  // we need to wrap xContent output in proper object to be able to parse it\n+        builder = highlightField.toXContent(builder, ToXContent.EMPTY_PARAMS);\n+        builder.endObject();\n+        XContentParser parser = XContentFactory.xContent(builder.bytes()).createParser(builder.bytes());\n+        HighlightField parsedField = HighlightField.fromXContent(parser);\n+        assertEquals(highlightField.getName(), parsedField.getName());\n+        assertArrayEquals(highlightField.getFragments(), parsedField.getFragments());","path":"core/src/test/java/org/elasticsearch/search/fetch/subphase/highlight/HighlightFieldTests.java","position":66,"original_position":66,"commit_id":"a15ba72f770695bbabb8104b97ebcac906a8c8f9","original_commit_id":"a15ba72f770695bbabb8104b97ebcac906a8c8f9","user":{"login":"jimczi","id":15977469,"avatar_url":"https://avatars.githubusercontent.com/u/15977469?v=3","gravatar_id":"","url":"https://api.github.com/users/jimczi","html_url":"https://github.com/jimczi","followers_url":"https://api.github.com/users/jimczi/followers","following_url":"https://api.github.com/users/jimczi/following{/other_user}","gists_url":"https://api.github.com/users/jimczi/gists{/gist_id}","starred_url":"https://api.github.com/users/jimczi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jimczi/subscriptions","organizations_url":"https://api.github.com/users/jimczi/orgs","repos_url":"https://api.github.com/users/jimczi/repos","events_url":"https://api.github.com/users/jimczi/events{/privacy}","received_events_url":"https://api.github.com/users/jimczi/received_events","type":"User","site_admin":false},"body":"assertEquals(highlightField, parsedField) ?","created_at":"2016-12-07T11:04:51Z","updated_at":"2016-12-07T11:07:11Z","html_url":"https://github.com/elastic/elasticsearch/pull/22022#discussion_r91271119","pull_request_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/22022","_links":{"self":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments/91271119"},"html":{"href":"https://github.com/elastic/elasticsearch/pull/22022#discussion_r91271119"},"pull_request":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/22022"}}},"pull_request":{"url":"https://api.github.com/repos/elastic/elasticsearch/pulls/22022","id":96899554,"html_url":"https://github.com/elastic/elasticsearch/pull/22022","diff_url":"https://github.com/elastic/elasticsearch/pull/22022.diff","patch_url":"https://github.com/elastic/elasticsearch/pull/22022.patch","issue_url":"https://api.github.com/repos/elastic/elasticsearch/issues/22022","number":22022,"state":"open","locked":false,"title":"Add fromXContent to HighlightField","user":{"login":"cbuescher","id":10398885,"avatar_url":"https://avatars.githubusercontent.com/u/10398885?v=3","gravatar_id":"","url":"https://api.github.com/users/cbuescher","html_url":"https://github.com/cbuescher","followers_url":"https://api.github.com/users/cbuescher/followers","following_url":"https://api.github.com/users/cbuescher/following{/other_user}","gists_url":"https://api.github.com/users/cbuescher/gists{/gist_id}","starred_url":"https://api.github.com/users/cbuescher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cbuescher/subscriptions","organizations_url":"https://api.github.com/users/cbuescher/orgs","repos_url":"https://api.github.com/users/cbuescher/repos","events_url":"https://api.github.com/users/cbuescher/events{/privacy}","received_events_url":"https://api.github.com/users/cbuescher/received_events","type":"User","site_admin":false},"body":"This adds a fromXContent method and unit test to the HighlightField class so we can parse it as part of a serch response. This is part of the preparation for parsing search responses on the client side.","created_at":"2016-12-07T10:49:09Z","updated_at":"2016-12-07T11:07:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ae9f71db6aaa19e0d1c8dcad02070b249525744b","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/22022/commits","review_comments_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/22022/comments","review_comment_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments{/number}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/issues/22022/comments","statuses_url":"https://api.github.com/repos/elastic/elasticsearch/statuses/a15ba72f770695bbabb8104b97ebcac906a8c8f9","head":{"label":"cbuescher:addParsing-highlightField","ref":"addParsing-highlightField","sha":"a15ba72f770695bbabb8104b97ebcac906a8c8f9","user":{"login":"cbuescher","id":10398885,"avatar_url":"https://avatars.githubusercontent.com/u/10398885?v=3","gravatar_id":"","url":"https://api.github.com/users/cbuescher","html_url":"https://github.com/cbuescher","followers_url":"https://api.github.com/users/cbuescher/followers","following_url":"https://api.github.com/users/cbuescher/following{/other_user}","gists_url":"https://api.github.com/users/cbuescher/gists{/gist_id}","starred_url":"https://api.github.com/users/cbuescher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cbuescher/subscriptions","organizations_url":"https://api.github.com/users/cbuescher/orgs","repos_url":"https://api.github.com/users/cbuescher/repos","events_url":"https://api.github.com/users/cbuescher/events{/privacy}","received_events_url":"https://api.github.com/users/cbuescher/received_events","type":"User","site_admin":false},"repo":{"id":28811483,"name":"elasticsearch","full_name":"cbuescher/elasticsearch","owner":{"login":"cbuescher","id":10398885,"avatar_url":"https://avatars.githubusercontent.com/u/10398885?v=3","gravatar_id":"","url":"https://api.github.com/users/cbuescher","html_url":"https://github.com/cbuescher","followers_url":"https://api.github.com/users/cbuescher/followers","following_url":"https://api.github.com/users/cbuescher/following{/other_user}","gists_url":"https://api.github.com/users/cbuescher/gists{/gist_id}","starred_url":"https://api.github.com/users/cbuescher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cbuescher/subscriptions","organizations_url":"https://api.github.com/users/cbuescher/orgs","repos_url":"https://api.github.com/users/cbuescher/repos","events_url":"https://api.github.com/users/cbuescher/events{/privacy}","received_events_url":"https://api.github.com/users/cbuescher/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/cbuescher/elasticsearch","description":"Open Source, Distributed, RESTful Search Engine","fork":true,"url":"https://api.github.com/repos/cbuescher/elasticsearch","forks_url":"https://api.github.com/repos/cbuescher/elasticsearch/forks","keys_url":"https://api.github.com/repos/cbuescher/elasticsearch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cbuescher/elasticsearch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cbuescher/elasticsearch/teams","hooks_url":"https://api.github.com/repos/cbuescher/elasticsearch/hooks","issue_events_url":"https://api.github.com/repos/cbuescher/elasticsearch/issues/events{/number}","events_url":"https://api.github.com/repos/cbuescher/elasticsearch/events","assignees_url":"https://api.github.com/repos/cbuescher/elasticsearch/assignees{/user}","branches_url":"https://api.github.com/repos/cbuescher/elasticsearch/branches{/branch}","tags_url":"https://api.github.com/repos/cbuescher/elasticsearch/tags","blobs_url":"https://api.github.com/repos/cbuescher/elasticsearch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cbuescher/elasticsearch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cbuescher/elasticsearch/git/refs{/sha}","trees_url":"https://api.github.com/repos/cbuescher/elasticsearch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cbuescher/elasticsearch/statuses/{sha}","languages_url":"https://api.github.com/repos/cbuescher/elasticsearch/languages","stargazers_url":"https://api.github.com/repos/cbuescher/elasticsearch/stargazers","contributors_url":"https://api.github.com/repos/cbuescher/elasticsearch/contributors","subscribers_url":"https://api.github.com/repos/cbuescher/elasticsearch/subscribers","subscription_url":"https://api.github.com/repos/cbuescher/elasticsearch/subscription","commits_url":"https://api.github.com/repos/cbuescher/elasticsearch/commits{/sha}","git_commits_url":"https://api.github.com/repos/cbuescher/elasticsearch/git/commits{/sha}","comments_url":"https://api.github.com/repos/cbuescher/elasticsearch/comments{/number}","issue_comment_url":"https://api.github.com/repos/cbuescher/elasticsearch/issues/comments{/number}","contents_url":"https://api.github.com/repos/cbuescher/elasticsearch/contents/{+path}","compare_url":"https://api.github.com/repos/cbuescher/elasticsearch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cbuescher/elasticsearch/merges","archive_url":"https://api.github.com/repos/cbuescher/elasticsearch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cbuescher/elasticsearch/downloads","issues_url":"https://api.github.com/repos/cbuescher/elasticsearch/issues{/number}","pulls_url":"https://api.github.com/repos/cbuescher/elasticsearch/pulls{/number}","milestones_url":"https://api.github.com/repos/cbuescher/elasticsearch/milestones{/number}","notifications_url":"https://api.github.com/repos/cbuescher/elasticsearch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cbuescher/elasticsearch/labels{/name}","releases_url":"https://api.github.com/repos/cbuescher/elasticsearch/releases{/id}","deployments_url":"https://api.github.com/repos/cbuescher/elasticsearch/deployments","created_at":"2015-01-05T12:21:34Z","updated_at":"2016-05-05T17:53:17Z","pushed_at":"2016-12-07T10:48:28Z","git_url":"git://github.com/cbuescher/elasticsearch.git","ssh_url":"git@github.com:cbuescher/elasticsearch.git","clone_url":"https://github.com/cbuescher/elasticsearch.git","svn_url":"https://github.com/cbuescher/elasticsearch","homepage":"http://elasticsearch.org","size":244152,"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:feature/high-level-rest-client","ref":"feature/high-level-rest-client","sha":"af9cced286f0d4a31c4e81acb2344cf8e4f9e66a","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-12-07T11:04:56Z","pushed_at":"2016-12-07T10:56:05Z","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":381883,"stargazers_count":19684,"watchers_count":19684,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":6760,"mirror_url":null,"open_issues_count":1193,"forks":6760,"open_issues":1193,"watchers":19684,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/22022"},"html":{"href":"https://github.com/elastic/elasticsearch/pull/22022"},"issue":{"href":"https://api.github.com/repos/elastic/elasticsearch/issues/22022"},"comments":{"href":"https://api.github.com/repos/elastic/elasticsearch/issues/22022/comments"},"review_comments":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/22022/comments"},"review_comment":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/22022/commits"},"statuses":{"href":"https://api.github.com/repos/elastic/elasticsearch/statuses/a15ba72f770695bbabb8104b97ebcac906a8c8f9"}}}}
{"actor":{"display_login":"jimczi"}}