{"action":"created","comment":{"url":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments/82640245","pull_request_review_id":3533289,"id":82640245,"diff_hunk":"@@ -134,115 +139,171 @@ private static Object extractValue(String[] pathElements, int index, Object curr\n         return null;\n     }\n \n-    public static Map<String, Object> filter(Map<String, Object> map, String[] includes, String[] excludes) {\n-        Map<String, Object> result = new HashMap<>();\n-        filter(map, result, includes == null ? Strings.EMPTY_ARRAY : includes, excludes == null ? Strings.EMPTY_ARRAY : excludes, new StringBuilder());\n-        return result;\n+    /**\n+     * Only keep properties in {@code map} that match the {@code includes} but\n+     * not the {@code excludes}. An empty list of includes is interpreted as a\n+     * wildcard while an empty list of excludes does not match anything.\n+     *\n+     * If a property matches both an include and an exclude, then the exclude\n+     * wins.\n+     *\n+     * If an object matches, then any of its sub properties are automatically\n+     * considered as matching as well, both for includes and excludes.\n+     *\n+     * Dots in field names are treated as sub objects. So for instance if a\n+     * document contains {@code a.b} as a property and {@code a} is an include,\n+     * then {@code a.b} will be kept in the filtered map.\n+     */\n+    public static Map<String, Object> filter(Map<String, ?> map, String[] includes, String[] excludes) {\n+        CharacterRunAutomaton matchAllAutomaton = new CharacterRunAutomaton(Automata.makeAnyString());","path":"core/src/main/java/org/elasticsearch/common/xcontent/support/XContentMapValues.java","position":42,"original_position":42,"commit_id":"21465f49cf6fa2b1c1cb14b4daade36872ee3684","original_commit_id":"21465f49cf6fa2b1c1cb14b4daade36872ee3684","user":{"login":"mikemccand","id":796508,"avatar_url":"https://avatars.githubusercontent.com/u/796508?v=3","gravatar_id":"","url":"https://api.github.com/users/mikemccand","html_url":"https://github.com/mikemccand","followers_url":"https://api.github.com/users/mikemccand/followers","following_url":"https://api.github.com/users/mikemccand/following{/other_user}","gists_url":"https://api.github.com/users/mikemccand/gists{/gist_id}","starred_url":"https://api.github.com/users/mikemccand/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikemccand/subscriptions","organizations_url":"https://api.github.com/users/mikemccand/orgs","repos_url":"https://api.github.com/users/mikemccand/repos","events_url":"https://api.github.com/users/mikemccand/events{/privacy}","received_events_url":"https://api.github.com/users/mikemccand/received_events","type":"User","site_admin":false},"body":"Isn't this invoked once per returned hit?  We should maybe (separate change) compile the automaton/a up front, and re-use that across all the hits?","created_at":"2016-10-10T16:43:28Z","updated_at":"2016-10-10T16:45:12Z","html_url":"https://github.com/elastic/elasticsearch/pull/20736#discussion_r82640245","pull_request_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/20736","_links":{"self":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments/82640245"},"html":{"href":"https://github.com/elastic/elasticsearch/pull/20736#discussion_r82640245"},"pull_request":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/20736"}}},"pull_request":{"url":"https://api.github.com/repos/elastic/elasticsearch/pulls/20736","id":87898358,"html_url":"https://github.com/elastic/elasticsearch/pull/20736","diff_url":"https://github.com/elastic/elasticsearch/pull/20736.diff","patch_url":"https://github.com/elastic/elasticsearch/pull/20736.patch","issue_url":"https://api.github.com/repos/elastic/elasticsearch/issues/20736","number":20736,"state":"closed","locked":false,"title":"Source filtering should treat dots in field names as sub objects.","user":{"login":"jpountz","id":299848,"avatar_url":"https://avatars.githubusercontent.com/u/299848?v=3","gravatar_id":"","url":"https://api.github.com/users/jpountz","html_url":"https://github.com/jpountz","followers_url":"https://api.github.com/users/jpountz/followers","following_url":"https://api.github.com/users/jpountz/following{/other_user}","gists_url":"https://api.github.com/users/jpountz/gists{/gist_id}","starred_url":"https://api.github.com/users/jpountz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jpountz/subscriptions","organizations_url":"https://api.github.com/users/jpountz/orgs","repos_url":"https://api.github.com/users/jpountz/repos","events_url":"https://api.github.com/users/jpountz/events{/privacy}","received_events_url":"https://api.github.com/users/jpountz/received_events","type":"User","site_admin":false},"body":"Mappings treat dots in field names as sub objects, for instance\r\n\r\n```\r\n{\r\n  \"a.b\": \"c\"\r\n}\r\n```\r\n\r\ngenerates the same dynamic mappings as\r\n\r\n```\r\n{\r\n  \"a\": {\r\n    \"b\": \"c\"\r\n  }\r\n}\r\n```\r\n\r\nSource filtering should be consistent with this behaviour so that an include\r\nlist containing `a` should include fields whose name is `a.b`.\r\n\r\nTo make this change easier, source filtering was refactored to use automata.\r\nThe ability to treat dots in field names as sub objects is provided by the\r\n`makeMatchDotsInFieldNames` method of `XContentMapValues`.\r\n\r\nCloses #20719","created_at":"2016-10-04T13:52:19Z","updated_at":"2016-10-10T16:45:12Z","closed_at":"2016-10-10T07:32:27Z","merged_at":"2016-10-10T07:32:27Z","merge_commit_sha":"8ab7ca5284581d59b3988024894a934504371092","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/20736/commits","review_comments_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/20736/comments","review_comment_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments{/number}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/issues/20736/comments","statuses_url":"https://api.github.com/repos/elastic/elasticsearch/statuses/21465f49cf6fa2b1c1cb14b4daade36872ee3684","head":{"label":"jpountz:fix/source_include_dots_in_field_names","ref":"fix/source_include_dots_in_field_names","sha":"21465f49cf6fa2b1c1cb14b4daade36872ee3684","user":{"login":"jpountz","id":299848,"avatar_url":"https://avatars.githubusercontent.com/u/299848?v=3","gravatar_id":"","url":"https://api.github.com/users/jpountz","html_url":"https://github.com/jpountz","followers_url":"https://api.github.com/users/jpountz/followers","following_url":"https://api.github.com/users/jpountz/following{/other_user}","gists_url":"https://api.github.com/users/jpountz/gists{/gist_id}","starred_url":"https://api.github.com/users/jpountz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jpountz/subscriptions","organizations_url":"https://api.github.com/users/jpountz/orgs","repos_url":"https://api.github.com/users/jpountz/repos","events_url":"https://api.github.com/users/jpountz/events{/privacy}","received_events_url":"https://api.github.com/users/jpountz/received_events","type":"User","site_admin":false},"repo":{"id":9633891,"name":"elasticsearch","full_name":"jpountz/elasticsearch","owner":{"login":"jpountz","id":299848,"avatar_url":"https://avatars.githubusercontent.com/u/299848?v=3","gravatar_id":"","url":"https://api.github.com/users/jpountz","html_url":"https://github.com/jpountz","followers_url":"https://api.github.com/users/jpountz/followers","following_url":"https://api.github.com/users/jpountz/following{/other_user}","gists_url":"https://api.github.com/users/jpountz/gists{/gist_id}","starred_url":"https://api.github.com/users/jpountz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jpountz/subscriptions","organizations_url":"https://api.github.com/users/jpountz/orgs","repos_url":"https://api.github.com/users/jpountz/repos","events_url":"https://api.github.com/users/jpountz/events{/privacy}","received_events_url":"https://api.github.com/users/jpountz/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jpountz/elasticsearch","description":"Open Source, Distributed, RESTful Search Engine","fork":true,"url":"https://api.github.com/repos/jpountz/elasticsearch","forks_url":"https://api.github.com/repos/jpountz/elasticsearch/forks","keys_url":"https://api.github.com/repos/jpountz/elasticsearch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jpountz/elasticsearch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jpountz/elasticsearch/teams","hooks_url":"https://api.github.com/repos/jpountz/elasticsearch/hooks","issue_events_url":"https://api.github.com/repos/jpountz/elasticsearch/issues/events{/number}","events_url":"https://api.github.com/repos/jpountz/elasticsearch/events","assignees_url":"https://api.github.com/repos/jpountz/elasticsearch/assignees{/user}","branches_url":"https://api.github.com/repos/jpountz/elasticsearch/branches{/branch}","tags_url":"https://api.github.com/repos/jpountz/elasticsearch/tags","blobs_url":"https://api.github.com/repos/jpountz/elasticsearch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jpountz/elasticsearch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jpountz/elasticsearch/git/refs{/sha}","trees_url":"https://api.github.com/repos/jpountz/elasticsearch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jpountz/elasticsearch/statuses/{sha}","languages_url":"https://api.github.com/repos/jpountz/elasticsearch/languages","stargazers_url":"https://api.github.com/repos/jpountz/elasticsearch/stargazers","contributors_url":"https://api.github.com/repos/jpountz/elasticsearch/contributors","subscribers_url":"https://api.github.com/repos/jpountz/elasticsearch/subscribers","subscription_url":"https://api.github.com/repos/jpountz/elasticsearch/subscription","commits_url":"https://api.github.com/repos/jpountz/elasticsearch/commits{/sha}","git_commits_url":"https://api.github.com/repos/jpountz/elasticsearch/git/commits{/sha}","comments_url":"https://api.github.com/repos/jpountz/elasticsearch/comments{/number}","issue_comment_url":"https://api.github.com/repos/jpountz/elasticsearch/issues/comments{/number}","contents_url":"https://api.github.com/repos/jpountz/elasticsearch/contents/{+path}","compare_url":"https://api.github.com/repos/jpountz/elasticsearch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jpountz/elasticsearch/merges","archive_url":"https://api.github.com/repos/jpountz/elasticsearch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jpountz/elasticsearch/downloads","issues_url":"https://api.github.com/repos/jpountz/elasticsearch/issues{/number}","pulls_url":"https://api.github.com/repos/jpountz/elasticsearch/pulls{/number}","milestones_url":"https://api.github.com/repos/jpountz/elasticsearch/milestones{/number}","notifications_url":"https://api.github.com/repos/jpountz/elasticsearch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jpountz/elasticsearch/labels{/name}","releases_url":"https://api.github.com/repos/jpountz/elasticsearch/releases{/id}","deployments_url":"https://api.github.com/repos/jpountz/elasticsearch/deployments","created_at":"2013-04-23T21:37:49Z","updated_at":"2016-02-18T01:44:50Z","pushed_at":"2016-10-10T07:32:31Z","git_url":"git://github.com/jpountz/elasticsearch.git","ssh_url":"git@github.com:jpountz/elasticsearch.git","clone_url":"https://github.com/jpountz/elasticsearch.git","svn_url":"https://github.com/jpountz/elasticsearch","homepage":"http://elasticsearch.org","size":220609,"stargazers_count":4,"watchers_count":4,"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":4,"default_branch":"master"}},"base":{"label":"elastic:master","ref":"master","sha":"059052899f235c1533e26b797d269d01052d0da5","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-10-10T16:21:36Z","pushed_at":"2016-10-10T16:43:27Z","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":358918,"stargazers_count":18753,"watchers_count":18753,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":6387,"mirror_url":null,"open_issues_count":1103,"forks":6387,"open_issues":1103,"watchers":18753,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/20736"},"html":{"href":"https://github.com/elastic/elasticsearch/pull/20736"},"issue":{"href":"https://api.github.com/repos/elastic/elasticsearch/issues/20736"},"comments":{"href":"https://api.github.com/repos/elastic/elasticsearch/issues/20736/comments"},"review_comments":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/20736/comments"},"review_comment":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/20736/commits"},"statuses":{"href":"https://api.github.com/repos/elastic/elasticsearch/statuses/21465f49cf6fa2b1c1cb14b4daade36872ee3684"}}}}
{"actor":{"display_login":"mikemccand"}}