{"action":"created","comment":{"url":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments/46523375","id":46523375,"diff_hunk":"@@ -0,0 +1,135 @@\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.profile;\n+\n+import org.apache.lucene.index.LeafReaderContext;\n+import org.apache.lucene.search.Collector;\n+import org.apache.lucene.search.LeafCollector;\n+\n+import java.io.IOException;\n+import java.util.ArrayList;\n+import java.util.List;\n+\n+/**\n+ * This class wraps a Lucene Collector and times the execution of:\n+ * - setScorer()\n+ * - collect()\n+ * - doSetNextReader()\n+ * - needsScores()\n+ *\n+ * InternalProfiler facilitates the linking of the the Collector graph\n+ */\n+public class InternalProfileCollector implements Collector {","path":"core/src/main/java/org/elasticsearch/search/profile/InternalProfileCollector.java","position":39,"original_position":39,"commit_id":"59b63c533fcaddcdfe4656e86a6f6c4cb1bc4a00","original_commit_id":"59b63c533fcaddcdfe4656e86a6f6c4cb1bc4a00","user":{"login":"s1monw","id":973334,"avatar_url":"https://avatars.githubusercontent.com/u/973334?v=3","gravatar_id":"","url":"https://api.github.com/users/s1monw","html_url":"https://github.com/s1monw","followers_url":"https://api.github.com/users/s1monw/followers","following_url":"https://api.github.com/users/s1monw/following{/other_user}","gists_url":"https://api.github.com/users/s1monw/gists{/gist_id}","starred_url":"https://api.github.com/users/s1monw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/s1monw/subscriptions","organizations_url":"https://api.github.com/users/s1monw/orgs","repos_url":"https://api.github.com/users/s1monw/repos","events_url":"https://api.github.com/users/s1monw/events{/privacy}","received_events_url":"https://api.github.com/users/s1monw/received_events","type":"User","site_admin":false},"body":"can this be final","created_at":"2015-12-03T08:19:02Z","updated_at":"2015-12-03T08:19:02Z","html_url":"https://github.com/elastic/elasticsearch/pull/14889#discussion_r46523375","pull_request_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/14889","_links":{"self":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments/46523375"},"html":{"href":"https://github.com/elastic/elasticsearch/pull/14889#discussion_r46523375"},"pull_request":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/14889"}}},"pull_request":{"url":"https://api.github.com/repos/elastic/elasticsearch/pulls/14889","id":51361157,"html_url":"https://github.com/elastic/elasticsearch/pull/14889","diff_url":"https://github.com/elastic/elasticsearch/pull/14889.diff","patch_url":"https://github.com/elastic/elasticsearch/pull/14889.patch","issue_url":"https://api.github.com/repos/elastic/elasticsearch/issues/14889","number":14889,"state":"open","locked":false,"title":"Search: Add query profiler","user":{"login":"polyfractal","id":1224228,"avatar_url":"https://avatars.githubusercontent.com/u/1224228?v=3","gravatar_id":"","url":"https://api.github.com/users/polyfractal","html_url":"https://github.com/polyfractal","followers_url":"https://api.github.com/users/polyfractal/followers","following_url":"https://api.github.com/users/polyfractal/following{/other_user}","gists_url":"https://api.github.com/users/polyfractal/gists{/gist_id}","starred_url":"https://api.github.com/users/polyfractal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/polyfractal/subscriptions","organizations_url":"https://api.github.com/users/polyfractal/orgs","repos_url":"https://api.github.com/users/polyfractal/repos","events_url":"https://api.github.com/users/polyfractal/events{/privacy}","received_events_url":"https://api.github.com/users/polyfractal/received_events","type":"User","site_admin":false},"body":"Followup to #12974 and #6699\r\n\r\nThis PR adds a query profiler to time the various components of a Search API Request.  It shows profiling information (query, rewrite, collectors) for each Lucene search on each shard in the request.\r\n\r\n### Request:\r\n\r\n```json\r\nGET /test/_search\r\n{\r\n  \"profile\": true,\r\n  \"query\" : {\r\n    \"match\" : { \"message\" : \"search test\" }\r\n  }\r\n}\r\n```\r\n\r\n### Response\r\n\r\n```js\r\n{\r\n   \"took\": 25,\r\n   \"timed_out\": false,\r\n   \"_shards\": {...},\r\n   \"hits\": {...},\r\n   \"profile\": {\r\n     \"shards\": [\r\n        {\r\n           \"id\": \"[htuC6YnSSSmKFq5UBt0YMA][test][0]\",\r\n           \"searches\": [\r\n              {\r\n                 \"query\": [\r\n                    {\r\n                       \"query_type\": \"BooleanQuery\",\r\n                       \"lucene\": \"message:search message:test\",\r\n                       \"time\": \"15.52889800ms\",\r\n                       \"breakdown\": {\r\n                          \"score\": 0,\r\n                          \"next_doc\": 24495,\r\n                          \"match\": 0,\r\n                          \"weight\": 8488388,\r\n                          \"build_scorer\": 7016015,\r\n                          \"advance\": 0\r\n                       },\r\n                       \"children\": [\r\n                          {\r\n                             \"query_type\": \"TermQuery\",\r\n                             \"lucene\": \"message:search\",\r\n                             \"time\": \"4.938855000ms\",\r\n                             \"breakdown\": {\r\n                                \"score\": 0,\r\n                                \"next_doc\": 18332,\r\n                                \"match\": 0,\r\n                                \"weight\": 2945570,\r\n                                \"build_scorer\": 1974953,\r\n                                \"advance\": 0\r\n                             }\r\n                          },\r\n                          {\r\n                             \"query_type\": \"TermQuery\",\r\n                             \"lucene\": \"message:test\",\r\n                             \"time\": \"0.5016660000ms\",\r\n                             \"breakdown\": {\r\n                                \"score\": 0,\r\n                                \"next_doc\": 0,\r\n                                \"match\": 0,\r\n                                \"weight\": 170534,\r\n                                \"build_scorer\": 331132,\r\n                                \"advance\": 0\r\n                             }\r\n                          }\r\n                       ]\r\n                    }\r\n                 ],\r\n                 \"rewrite_time\": 185002,\r\n                 \"collector\": [\r\n                    {\r\n                       \"name\": \"SimpleTopScoreDocCollector\",\r\n                       \"reason\": \"search_top_hits\",\r\n                       \"time\": \"2.206529000ms\"\r\n                    }\r\n                 ]\r\n              }\r\n           ]\r\n        }\r\n     ]\r\n  }\r\n}\r\n```\r\n\r\n/cc @jpountz \r\n","created_at":"2015-11-20T14:18:16Z","updated_at":"2015-12-03T08:19:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b7eb5bab2709a9b9952713e08c97cbb38e2ae055","assignee":{"login":"s1monw","id":973334,"avatar_url":"https://avatars.githubusercontent.com/u/973334?v=3","gravatar_id":"","url":"https://api.github.com/users/s1monw","html_url":"https://github.com/s1monw","followers_url":"https://api.github.com/users/s1monw/followers","following_url":"https://api.github.com/users/s1monw/following{/other_user}","gists_url":"https://api.github.com/users/s1monw/gists{/gist_id}","starred_url":"https://api.github.com/users/s1monw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/s1monw/subscriptions","organizations_url":"https://api.github.com/users/s1monw/orgs","repos_url":"https://api.github.com/users/s1monw/repos","events_url":"https://api.github.com/users/s1monw/events{/privacy}","received_events_url":"https://api.github.com/users/s1monw/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/14889/commits","review_comments_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/14889/comments","review_comment_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments{/number}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/issues/14889/comments","statuses_url":"https://api.github.com/repos/elastic/elasticsearch/statuses/59b63c533fcaddcdfe4656e86a6f6c4cb1bc4a00","head":{"label":"elastic:query_profiler","ref":"query_profiler","sha":"59b63c533fcaddcdfe4656e86a6f6c4cb1bc4a00","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-12-03T07:54:06Z","pushed_at":"2015-12-03T07:27:28Z","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":225478,"stargazers_count":13812,"watchers_count":13812,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":4579,"mirror_url":null,"open_issues_count":1264,"forks":4579,"open_issues":1264,"watchers":13812,"default_branch":"master"}},"base":{"label":"elastic:master","ref":"master","sha":"5a18f740ba38fede262b3625028cbde0c789bcfb","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-12-03T07:54:06Z","pushed_at":"2015-12-03T07:27:28Z","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":225478,"stargazers_count":13812,"watchers_count":13812,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":4579,"mirror_url":null,"open_issues_count":1264,"forks":4579,"open_issues":1264,"watchers":13812,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/14889"},"html":{"href":"https://github.com/elastic/elasticsearch/pull/14889"},"issue":{"href":"https://api.github.com/repos/elastic/elasticsearch/issues/14889"},"comments":{"href":"https://api.github.com/repos/elastic/elasticsearch/issues/14889/comments"},"review_comments":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/14889/comments"},"review_comment":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/14889/commits"},"statuses":{"href":"https://api.github.com/repos/elastic/elasticsearch/statuses/59b63c533fcaddcdfe4656e86a6f6c4cb1bc4a00"}}}}