{"action":"created","comment":{"url":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/pulls/comments/82513257","pull_request_review_id":3417784,"id":82513257,"diff_hunk":"@@ -1,32 +1,21 @@\n [[scroll]]\n-=== Scroll\n+=== 游标查询 \n \n-A `scroll` query (((\"scroll API))) is used to retrieve\n-large numbers of documents from Elasticsearch efficiently, without paying the\n-penalty of deep pagination.\n+`scroll` 查询 (((\"scroll API)))  可以用来对 Elasticsearch 有效地执行大批量的文档查询，而又不用付出深度分页那种代价。\n \n-Scrolling allows us to(((\"scrolled search\"))) do an initial search and to keep pulling\n-batches of results from Elasticsearch until there are no more results left.\n-It's a bit like a _cursor_ in (((\"cursors\")))a traditional database.\n+游标查询允许我们 (((\"scrolled search\"))) 先做查询初始化，然后再批量地拉取结果。\n+这有点儿像传统数据库中的 _cursor_  (((\"cursors\"))) 。\n \n-A scrolled search takes a snapshot in time. It doesn't see any changes that\n-are made to the index after the initial search request has been made. It does\n-this by keeping the old data files around, so that it can preserve its ``view''\n-on what the index looked like at the time it started.\n+游标查询会取某个时间点的快照数据。 查询初始化之后索引上的任何变化会被它忽略。\n+它通过保存旧的数据文件来实现这个特性，结果就像保留初始化时的索引视图一样。\n \n-The costly part of deep pagination is the global sorting of results, but if we\n-disable sorting, then we can return all documents quite cheaply. To do this, we\n-sort by `_doc`. This instructs Elasticsearch just return the next batch of \n-results from every shard that still has results to return.\n+深度分页的代价根源是结果集全局排序，如果去掉全局排序的特性的话查询结果的成本就会很低。\n+游标查询可以用字段 `_doc` 来排序。 这个指令让 Elasticsearch 从还有结果的每个分片仅仅返回下一批结果。\n \n-To scroll through results, we execute a search request and set the `scroll` value to\n-the length of time we want to keep the scroll window open. The scroll expiry \n-time is refreshed every time we run a scroll request, so it only needs to be long enough\n-to process the current batch of results, not all of the documents that match\n-the query. The timeout is important because keeping the scroll window open\n-consumes resources and we want to free them as soon as they are no longer needed. \n-Setting the timeout enables Elasticsearch to automatically free the resources \n-after a small period of inactivity.\n+启用游标查询可以通过在查询的时候设置参数 `scroll` 的值，为一个我们期望游标查询打开的时间窗口。\n+游标查询的过期时间会在每次做查询的时候刷新，所以这个时间只需要足够处理当前批的结果就可以了，而不是处理查询结果的所有文档。","path":"060_Distributed_Search/20_Scroll.asciidoc","position":38,"original_position":39,"commit_id":"2d33b7d11ea777540be71b6d33362231739ff022","original_commit_id":"2d33b7d11ea777540be71b6d33362231739ff022","user":{"login":"tangmisi","id":19425897,"avatar_url":"https://avatars.githubusercontent.com/u/19425897?v=3","gravatar_id":"","url":"https://api.github.com/users/tangmisi","html_url":"https://github.com/tangmisi","followers_url":"https://api.github.com/users/tangmisi/followers","following_url":"https://api.github.com/users/tangmisi/following{/other_user}","gists_url":"https://api.github.com/users/tangmisi/gists{/gist_id}","starred_url":"https://api.github.com/users/tangmisi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tangmisi/subscriptions","organizations_url":"https://api.github.com/users/tangmisi/orgs","repos_url":"https://api.github.com/users/tangmisi/repos","events_url":"https://api.github.com/users/tangmisi/events{/privacy}","received_events_url":"https://api.github.com/users/tangmisi/received_events","type":"User","site_admin":false},"body":"而不是处理查询结果的所有文档--》而不是处理查询结果的所有文档的所需时间","created_at":"2016-10-09T02:21:37Z","updated_at":"2016-10-09T02:21:37Z","html_url":"https://github.com/elasticsearch-cn/elasticsearch-definitive-guide/pull/247#discussion_r82513257","pull_request_url":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/pulls/247","_links":{"self":{"href":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/pulls/comments/82513257"},"html":{"href":"https://github.com/elasticsearch-cn/elasticsearch-definitive-guide/pull/247#discussion_r82513257"},"pull_request":{"href":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/pulls/247"}}},"pull_request":{"url":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/pulls/247","id":83946832,"html_url":"https://github.com/elasticsearch-cn/elasticsearch-definitive-guide/pull/247","diff_url":"https://github.com/elasticsearch-cn/elasticsearch-definitive-guide/pull/247.diff","patch_url":"https://github.com/elasticsearch-cn/elasticsearch-definitive-guide/pull/247.patch","issue_url":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/issues/247","number":247,"state":"open","locked":false,"title":"Chapter/chapter9 part5","user":{"login":"cdma","id":1021566,"avatar_url":"https://avatars.githubusercontent.com/u/1021566?v=3","gravatar_id":"","url":"https://api.github.com/users/cdma","html_url":"https://github.com/cdma","followers_url":"https://api.github.com/users/cdma/followers","following_url":"https://api.github.com/users/cdma/following{/other_user}","gists_url":"https://api.github.com/users/cdma/gists{/gist_id}","starred_url":"https://api.github.com/users/cdma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cdma/subscriptions","organizations_url":"https://api.github.com/users/cdma/orgs","repos_url":"https://api.github.com/users/cdma/repos","events_url":"https://api.github.com/users/cdma/events{/privacy}","received_events_url":"https://api.github.com/users/cdma/received_events","type":"User","site_admin":false},"body":"chapter/chapter9_part5\r\n060_Distributed_Search/20_Scroll.asciidoc\r\n","created_at":"2016-09-05T03:44:07Z","updated_at":"2016-10-09T02:21:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"817a906618ecbc60e0b5531f0577006df2947290","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/pulls/247/commits","review_comments_url":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/pulls/247/comments","review_comment_url":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/pulls/comments{/number}","comments_url":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/issues/247/comments","statuses_url":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/statuses/2d33b7d11ea777540be71b6d33362231739ff022","head":{"label":"cdma:chapter/chapter9_part5","ref":"chapter/chapter9_part5","sha":"2d33b7d11ea777540be71b6d33362231739ff022","user":{"login":"cdma","id":1021566,"avatar_url":"https://avatars.githubusercontent.com/u/1021566?v=3","gravatar_id":"","url":"https://api.github.com/users/cdma","html_url":"https://github.com/cdma","followers_url":"https://api.github.com/users/cdma/followers","following_url":"https://api.github.com/users/cdma/following{/other_user}","gists_url":"https://api.github.com/users/cdma/gists{/gist_id}","starred_url":"https://api.github.com/users/cdma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cdma/subscriptions","organizations_url":"https://api.github.com/users/cdma/orgs","repos_url":"https://api.github.com/users/cdma/repos","events_url":"https://api.github.com/users/cdma/events{/privacy}","received_events_url":"https://api.github.com/users/cdma/received_events","type":"User","site_admin":false},"repo":{"id":64713883,"name":"elasticsearch-definitive-guide","full_name":"cdma/elasticsearch-definitive-guide","owner":{"login":"cdma","id":1021566,"avatar_url":"https://avatars.githubusercontent.com/u/1021566?v=3","gravatar_id":"","url":"https://api.github.com/users/cdma","html_url":"https://github.com/cdma","followers_url":"https://api.github.com/users/cdma/followers","following_url":"https://api.github.com/users/cdma/following{/other_user}","gists_url":"https://api.github.com/users/cdma/gists{/gist_id}","starred_url":"https://api.github.com/users/cdma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cdma/subscriptions","organizations_url":"https://api.github.com/users/cdma/orgs","repos_url":"https://api.github.com/users/cdma/repos","events_url":"https://api.github.com/users/cdma/events{/privacy}","received_events_url":"https://api.github.com/users/cdma/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/cdma/elasticsearch-definitive-guide","description":"欢迎加QQ群：109764489，贡献力量！","fork":true,"url":"https://api.github.com/repos/cdma/elasticsearch-definitive-guide","forks_url":"https://api.github.com/repos/cdma/elasticsearch-definitive-guide/forks","keys_url":"https://api.github.com/repos/cdma/elasticsearch-definitive-guide/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cdma/elasticsearch-definitive-guide/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cdma/elasticsearch-definitive-guide/teams","hooks_url":"https://api.github.com/repos/cdma/elasticsearch-definitive-guide/hooks","issue_events_url":"https://api.github.com/repos/cdma/elasticsearch-definitive-guide/issues/events{/number}","events_url":"https://api.github.com/repos/cdma/elasticsearch-definitive-guide/events","assignees_url":"https://api.github.com/repos/cdma/elasticsearch-definitive-guide/assignees{/user}","branches_url":"https://api.github.com/repos/cdma/elasticsearch-definitive-guide/branches{/branch}","tags_url":"https://api.github.com/repos/cdma/elasticsearch-definitive-guide/tags","blobs_url":"https://api.github.com/repos/cdma/elasticsearch-definitive-guide/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cdma/elasticsearch-definitive-guide/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cdma/elasticsearch-definitive-guide/git/refs{/sha}","trees_url":"https://api.github.com/repos/cdma/elasticsearch-definitive-guide/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cdma/elasticsearch-definitive-guide/statuses/{sha}","languages_url":"https://api.github.com/repos/cdma/elasticsearch-definitive-guide/languages","stargazers_url":"https://api.github.com/repos/cdma/elasticsearch-definitive-guide/stargazers","contributors_url":"https://api.github.com/repos/cdma/elasticsearch-definitive-guide/contributors","subscribers_url":"https://api.github.com/repos/cdma/elasticsearch-definitive-guide/subscribers","subscription_url":"https://api.github.com/repos/cdma/elasticsearch-definitive-guide/subscription","commits_url":"https://api.github.com/repos/cdma/elasticsearch-definitive-guide/commits{/sha}","git_commits_url":"https://api.github.com/repos/cdma/elasticsearch-definitive-guide/git/commits{/sha}","comments_url":"https://api.github.com/repos/cdma/elasticsearch-definitive-guide/comments{/number}","issue_comment_url":"https://api.github.com/repos/cdma/elasticsearch-definitive-guide/issues/comments{/number}","contents_url":"https://api.github.com/repos/cdma/elasticsearch-definitive-guide/contents/{+path}","compare_url":"https://api.github.com/repos/cdma/elasticsearch-definitive-guide/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cdma/elasticsearch-definitive-guide/merges","archive_url":"https://api.github.com/repos/cdma/elasticsearch-definitive-guide/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cdma/elasticsearch-definitive-guide/downloads","issues_url":"https://api.github.com/repos/cdma/elasticsearch-definitive-guide/issues{/number}","pulls_url":"https://api.github.com/repos/cdma/elasticsearch-definitive-guide/pulls{/number}","milestones_url":"https://api.github.com/repos/cdma/elasticsearch-definitive-guide/milestones{/number}","notifications_url":"https://api.github.com/repos/cdma/elasticsearch-definitive-guide/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cdma/elasticsearch-definitive-guide/labels{/name}","releases_url":"https://api.github.com/repos/cdma/elasticsearch-definitive-guide/releases{/id}","deployments_url":"https://api.github.com/repos/cdma/elasticsearch-definitive-guide/deployments","created_at":"2016-08-02T01:31:00Z","updated_at":"2016-08-02T01:31:02Z","pushed_at":"2016-10-08T16:01:27Z","git_url":"git://github.com/cdma/elasticsearch-definitive-guide.git","ssh_url":"git@github.com:cdma/elasticsearch-definitive-guide.git","clone_url":"https://github.com/cdma/elasticsearch-definitive-guide.git","svn_url":"https://github.com/cdma/elasticsearch-definitive-guide","homepage":"","size":8105,"stargazers_count":0,"watchers_count":0,"language":"HTML","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"cn"}},"base":{"label":"elasticsearch-cn:cn","ref":"cn","sha":"c283d6758af22dfe5db416012d9a2d4330daaf0d","user":{"login":"elasticsearch-cn","id":2517572,"avatar_url":"https://avatars.githubusercontent.com/u/2517572?v=3","gravatar_id":"","url":"https://api.github.com/users/elasticsearch-cn","html_url":"https://github.com/elasticsearch-cn","followers_url":"https://api.github.com/users/elasticsearch-cn/followers","following_url":"https://api.github.com/users/elasticsearch-cn/following{/other_user}","gists_url":"https://api.github.com/users/elasticsearch-cn/gists{/gist_id}","starred_url":"https://api.github.com/users/elasticsearch-cn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elasticsearch-cn/subscriptions","organizations_url":"https://api.github.com/users/elasticsearch-cn/orgs","repos_url":"https://api.github.com/users/elasticsearch-cn/repos","events_url":"https://api.github.com/users/elasticsearch-cn/events{/privacy}","received_events_url":"https://api.github.com/users/elasticsearch-cn/received_events","type":"Organization","site_admin":false},"repo":{"id":20916742,"name":"elasticsearch-definitive-guide","full_name":"elasticsearch-cn/elasticsearch-definitive-guide","owner":{"login":"elasticsearch-cn","id":2517572,"avatar_url":"https://avatars.githubusercontent.com/u/2517572?v=3","gravatar_id":"","url":"https://api.github.com/users/elasticsearch-cn","html_url":"https://github.com/elasticsearch-cn","followers_url":"https://api.github.com/users/elasticsearch-cn/followers","following_url":"https://api.github.com/users/elasticsearch-cn/following{/other_user}","gists_url":"https://api.github.com/users/elasticsearch-cn/gists{/gist_id}","starred_url":"https://api.github.com/users/elasticsearch-cn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elasticsearch-cn/subscriptions","organizations_url":"https://api.github.com/users/elasticsearch-cn/orgs","repos_url":"https://api.github.com/users/elasticsearch-cn/repos","events_url":"https://api.github.com/users/elasticsearch-cn/events{/privacy}","received_events_url":"https://api.github.com/users/elasticsearch-cn/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/elasticsearch-cn/elasticsearch-definitive-guide","description":"欢迎加QQ群：109764489，贡献力量！","fork":true,"url":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide","forks_url":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/forks","keys_url":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/keys{/key_id}","collaborators_url":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/teams","hooks_url":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/hooks","issue_events_url":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/issues/events{/number}","events_url":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/events","assignees_url":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/assignees{/user}","branches_url":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/branches{/branch}","tags_url":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/tags","blobs_url":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/git/refs{/sha}","trees_url":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/git/trees{/sha}","statuses_url":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/statuses/{sha}","languages_url":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/languages","stargazers_url":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/stargazers","contributors_url":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/contributors","subscribers_url":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/subscribers","subscription_url":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/subscription","commits_url":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/commits{/sha}","git_commits_url":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/git/commits{/sha}","comments_url":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/comments{/number}","issue_comment_url":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/issues/comments{/number}","contents_url":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/contents/{+path}","compare_url":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/compare/{base}...{head}","merges_url":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/merges","archive_url":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/downloads","issues_url":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/issues{/number}","pulls_url":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/pulls{/number}","milestones_url":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/milestones{/number}","notifications_url":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/labels{/name}","releases_url":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/releases{/id}","deployments_url":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/deployments","created_at":"2014-06-17T08:56:29Z","updated_at":"2016-09-24T04:51:06Z","pushed_at":"2016-10-08T16:19:27Z","git_url":"git://github.com/elasticsearch-cn/elasticsearch-definitive-guide.git","ssh_url":"git@github.com:elasticsearch-cn/elasticsearch-definitive-guide.git","clone_url":"https://github.com/elasticsearch-cn/elasticsearch-definitive-guide.git","svn_url":"https://github.com/elasticsearch-cn/elasticsearch-definitive-guide","homepage":"","size":8952,"stargazers_count":76,"watchers_count":76,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":82,"mirror_url":null,"open_issues_count":246,"forks":82,"open_issues":246,"watchers":76,"default_branch":"cn"}},"_links":{"self":{"href":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/pulls/247"},"html":{"href":"https://github.com/elasticsearch-cn/elasticsearch-definitive-guide/pull/247"},"issue":{"href":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/issues/247"},"comments":{"href":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/issues/247/comments"},"review_comments":{"href":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/pulls/247/comments"},"review_comment":{"href":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/pulls/247/commits"},"statuses":{"href":"https://api.github.com/repos/elasticsearch-cn/elasticsearch-definitive-guide/statuses/2d33b7d11ea777540be71b6d33362231739ff022"}}}}
{"actor":{"display_login":"tangmisi"}}