{"action":"created","comment":{"url":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments/28856859","id":28856859,"diff_hunk":"@@ -98,14 +103,60 @@ public void testEscapeJson() throws IOException {\n                 escaped.append(c);\n             }\n             StringWriter target = new StringWriter();\n-            assertThat(escaped.toString(), equalTo(JsonEscapingMustacheFactory.escape(writer.toString(), target).toString()));\n+            assertThat(escaped.toString(), equalTo(InternalMustacheFactory.escape(writer.toString(), target).toString()));\n         }\n     }\n \n+    @Test @Repeat(iterations = 5)\n+    public void testArrayAccess() throws Exception {\n+        Map<String, Object> vars = new HashMap<>();\n+        Object data = randomFrom(\n+                new String[] { \"foo\", \"bar\" },\n+                ImmutableList.of(\"foo\", \"bar\"),\n+                ImmutableSet.of(\"foo\", \"bar\"));\n+        vars.put(\"data\", data);\n+        Object output = engine.execute(engine.compile(\"{{data.0}} {{data.1}}\"), vars);\n+        assertThat(output, notNullValue());\n+        assertThat(output, instanceOf(BytesReference.class));\n+        BytesReference bytes = (BytesReference) output;\n+        assertThat(bytes.toUtf8(), equalTo(\"foo bar\"));\n+    }\n+\n+    @Test @Repeat(iterations = 5)\n+    public void testArrayInArrayAccess() throws Exception {\n+        Map<String, Object> vars = new HashMap<>();\n+        Object data = randomFrom(\n+                new String[][] { new String[] {\"foo\", \"bar\" }},\n+                ImmutableList.of(new String[] {\"foo\", \"bar\" }),\n+                ImmutableSet.of(new String[] {\"foo\", \"bar\" })\n+        );\n+        vars.put(\"data\", data);\n+        Object output = engine.execute(engine.compile(\"{{data.0.0}} {{data.0.1}}\"), vars);\n+        assertThat(output, notNullValue());\n+        assertThat(output, instanceOf(BytesReference.class));\n+        BytesReference bytes = (BytesReference) output;\n+        assertThat(bytes.toUtf8(), equalTo(\"foo bar\"));\n+    }\n+\n+    @Test @Repeat(iterations = 5)","path":"src/test/java/org/elasticsearch/script/mustache/MustacheScriptEngineTest.java","position":107,"original_position":107,"commit_id":"09e5cb375f61dd5599cd2cd0bfb7d0c23922a484","original_commit_id":"09e5cb375f61dd5599cd2cd0bfb7d0c23922a484","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":"See above","created_at":"2015-04-22T09:29:38Z","updated_at":"2015-04-22T09:29:38Z","html_url":"https://github.com/elastic/elasticsearch/pull/10712#discussion_r28856859","pull_request_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/10712","_links":{"self":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments/28856859"},"html":{"href":"https://github.com/elastic/elasticsearch/pull/10712#discussion_r28856859"},"pull_request":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/10712"}}},"pull_request":{"url":"https://api.github.com/repos/elastic/elasticsearch/pulls/10712","id":33817699,"html_url":"https://github.com/elastic/elasticsearch/pull/10712","diff_url":"https://github.com/elastic/elasticsearch/pull/10712.diff","patch_url":"https://github.com/elastic/elasticsearch/pull/10712.patch","issue_url":"https://api.github.com/repos/elastic/elasticsearch/issues/10712","number":10712,"state":"open","locked":false,"title":"Extended mustach language to support direct array/collection access","user":{"login":"uboness","id":211019,"avatar_url":"https://avatars.githubusercontent.com/u/211019?v=3","gravatar_id":"","url":"https://api.github.com/users/uboness","html_url":"https://github.com/uboness","followers_url":"https://api.github.com/users/uboness/followers","following_url":"https://api.github.com/users/uboness/following{/other_user}","gists_url":"https://api.github.com/users/uboness/gists{/gist_id}","starred_url":"https://api.github.com/users/uboness/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uboness/subscriptions","organizations_url":"https://api.github.com/users/uboness/orgs","repos_url":"https://api.github.com/users/uboness/repos","events_url":"https://api.github.com/users/uboness/events{/privacy}","received_events_url":"https://api.github.com/users/uboness/received_events","type":"User","site_admin":false},"body":"Customzied our internal `MustacheFactory` to supports array/collection access syntax in the form of `array_or_collection.X` where `array_or_collection` refers to an array or a collection and `X` is the index into it. For example, referring to the \"key\" field in the 3rd item in the \"array\" array can be expressed as `array.3.key`.\r\n\r\nNote, although not part of the official mustache specs, `mustache.js` support this and users may expect to have this support.","created_at":"2015-04-22T00:58:45Z","updated_at":"2015-04-22T09:29:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6112e95edfb316d66926fef4dfc1ac04d14fffd7","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/10712/commits","review_comments_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/10712/comments","review_comment_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments{/number}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/issues/10712/comments","statuses_url":"https://api.github.com/repos/elastic/elasticsearch/statuses/09e5cb375f61dd5599cd2cd0bfb7d0c23922a484","head":{"label":"uboness:enhance/mustache_array_access","ref":"enhance/mustache_array_access","sha":"09e5cb375f61dd5599cd2cd0bfb7d0c23922a484","user":{"login":"uboness","id":211019,"avatar_url":"https://avatars.githubusercontent.com/u/211019?v=3","gravatar_id":"","url":"https://api.github.com/users/uboness","html_url":"https://github.com/uboness","followers_url":"https://api.github.com/users/uboness/followers","following_url":"https://api.github.com/users/uboness/following{/other_user}","gists_url":"https://api.github.com/users/uboness/gists{/gist_id}","starred_url":"https://api.github.com/users/uboness/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uboness/subscriptions","organizations_url":"https://api.github.com/users/uboness/orgs","repos_url":"https://api.github.com/users/uboness/repos","events_url":"https://api.github.com/users/uboness/events{/privacy}","received_events_url":"https://api.github.com/users/uboness/received_events","type":"User","site_admin":false},"repo":{"id":4145462,"name":"elasticsearch","full_name":"uboness/elasticsearch","owner":{"login":"uboness","id":211019,"avatar_url":"https://avatars.githubusercontent.com/u/211019?v=3","gravatar_id":"","url":"https://api.github.com/users/uboness","html_url":"https://github.com/uboness","followers_url":"https://api.github.com/users/uboness/followers","following_url":"https://api.github.com/users/uboness/following{/other_user}","gists_url":"https://api.github.com/users/uboness/gists{/gist_id}","starred_url":"https://api.github.com/users/uboness/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uboness/subscriptions","organizations_url":"https://api.github.com/users/uboness/orgs","repos_url":"https://api.github.com/users/uboness/repos","events_url":"https://api.github.com/users/uboness/events{/privacy}","received_events_url":"https://api.github.com/users/uboness/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/uboness/elasticsearch","description":"Open Source, Distributed, RESTful Search Engine","fork":true,"url":"https://api.github.com/repos/uboness/elasticsearch","forks_url":"https://api.github.com/repos/uboness/elasticsearch/forks","keys_url":"https://api.github.com/repos/uboness/elasticsearch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/uboness/elasticsearch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/uboness/elasticsearch/teams","hooks_url":"https://api.github.com/repos/uboness/elasticsearch/hooks","issue_events_url":"https://api.github.com/repos/uboness/elasticsearch/issues/events{/number}","events_url":"https://api.github.com/repos/uboness/elasticsearch/events","assignees_url":"https://api.github.com/repos/uboness/elasticsearch/assignees{/user}","branches_url":"https://api.github.com/repos/uboness/elasticsearch/branches{/branch}","tags_url":"https://api.github.com/repos/uboness/elasticsearch/tags","blobs_url":"https://api.github.com/repos/uboness/elasticsearch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/uboness/elasticsearch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/uboness/elasticsearch/git/refs{/sha}","trees_url":"https://api.github.com/repos/uboness/elasticsearch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/uboness/elasticsearch/statuses/{sha}","languages_url":"https://api.github.com/repos/uboness/elasticsearch/languages","stargazers_url":"https://api.github.com/repos/uboness/elasticsearch/stargazers","contributors_url":"https://api.github.com/repos/uboness/elasticsearch/contributors","subscribers_url":"https://api.github.com/repos/uboness/elasticsearch/subscribers","subscription_url":"https://api.github.com/repos/uboness/elasticsearch/subscription","commits_url":"https://api.github.com/repos/uboness/elasticsearch/commits{/sha}","git_commits_url":"https://api.github.com/repos/uboness/elasticsearch/git/commits{/sha}","comments_url":"https://api.github.com/repos/uboness/elasticsearch/comments{/number}","issue_comment_url":"https://api.github.com/repos/uboness/elasticsearch/issues/comments{/number}","contents_url":"https://api.github.com/repos/uboness/elasticsearch/contents/{+path}","compare_url":"https://api.github.com/repos/uboness/elasticsearch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/uboness/elasticsearch/merges","archive_url":"https://api.github.com/repos/uboness/elasticsearch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/uboness/elasticsearch/downloads","issues_url":"https://api.github.com/repos/uboness/elasticsearch/issues{/number}","pulls_url":"https://api.github.com/repos/uboness/elasticsearch/pulls{/number}","milestones_url":"https://api.github.com/repos/uboness/elasticsearch/milestones{/number}","notifications_url":"https://api.github.com/repos/uboness/elasticsearch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/uboness/elasticsearch/labels{/name}","releases_url":"https://api.github.com/repos/uboness/elasticsearch/releases{/id}","created_at":"2012-04-26T07:45:06Z","updated_at":"2014-07-17T09:58:03Z","pushed_at":"2015-04-22T00:55:12Z","git_url":"git://github.com/uboness/elasticsearch.git","ssh_url":"git@github.com:uboness/elasticsearch.git","clone_url":"https://github.com/uboness/elasticsearch.git","svn_url":"https://github.com/uboness/elasticsearch","homepage":"http://elasticsearch.org","size":94469,"stargazers_count":2,"watchers_count":2,"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":2,"default_branch":"master"}},"base":{"label":"elastic:master","ref":"master","sha":"b7ab3789963b781a7d2ff0bba899c014112a5340","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}","created_at":"2010-02-08T13:20:56Z","updated_at":"2015-04-22T09:15:13Z","pushed_at":"2015-04-22T09:15:12Z","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":"http://elasticsearch.org","size":334015,"stargazers_count":10890,"watchers_count":10890,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":3421,"mirror_url":null,"open_issues_count":1114,"forks":3421,"open_issues":1114,"watchers":10890,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/10712"},"html":{"href":"https://github.com/elastic/elasticsearch/pull/10712"},"issue":{"href":"https://api.github.com/repos/elastic/elasticsearch/issues/10712"},"comments":{"href":"https://api.github.com/repos/elastic/elasticsearch/issues/10712/comments"},"review_comments":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/10712/comments"},"review_comment":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/10712/commits"},"statuses":{"href":"https://api.github.com/repos/elastic/elasticsearch/statuses/09e5cb375f61dd5599cd2cd0bfb7d0c23922a484"}}}}