{"action":"opened","issue":{"url":"https://api.github.com/repos/elastic/elasticsearch-dsl-py/issues/126","labels_url":"https://api.github.com/repos/elastic/elasticsearch-dsl-py/issues/126/labels{/name}","comments_url":"https://api.github.com/repos/elastic/elasticsearch-dsl-py/issues/126/comments","events_url":"https://api.github.com/repos/elastic/elasticsearch-dsl-py/issues/126/events","html_url":"https://github.com/elastic/elasticsearch-dsl-py/issues/126","id":68467707,"number":126,"title":"Can't paginate using elasticsearch_dsl","user":{"login":"mamikonyana","id":2184519,"avatar_url":"https://avatars.githubusercontent.com/u/2184519?v=3","gravatar_id":"","url":"https://api.github.com/users/mamikonyana","html_url":"https://github.com/mamikonyana","followers_url":"https://api.github.com/users/mamikonyana/followers","following_url":"https://api.github.com/users/mamikonyana/following{/other_user}","gists_url":"https://api.github.com/users/mamikonyana/gists{/gist_id}","starred_url":"https://api.github.com/users/mamikonyana/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mamikonyana/subscriptions","organizations_url":"https://api.github.com/users/mamikonyana/orgs","repos_url":"https://api.github.com/users/mamikonyana/repos","events_url":"https://api.github.com/users/mamikonyana/events{/privacy}","received_events_url":"https://api.github.com/users/mamikonyana/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-04-14T18:50:37Z","updated_at":"2015-04-14T18:50:37Z","closed_at":null,"body":"When I want to paginate through the search results, not iterate as the `scan` does from `elasticsearch.helpers`.\r\n\r\nMy current workaround is something like this\r\n```\r\nsearch = Search()\r\n...\r\n# construct your search query\r\n...\r\nresult = search.params(search_type='scan', scroll='1m').execute()\r\nscroll_id = result.scroll_id\r\n# Now start using scroll_id to do the pagination,\r\n# but I have to use Elasticsearch.scroll which returns dictionaries not a Result object\r\nclient = connections.get_connection()\r\nwhile data_to_paginate:\r\n  result = Response(client.scroll(scroll_id, scroll='1m'))\r\n```\r\nThere probably should be a helper function that should abstract at least the following part\r\n```\r\nclient = connections.get_connection()\r\nresult = Response(client.scroll(scroll_id, scroll='1m'))\r\n```\r\nMaybe even getting the scroll_id from the result. Basically the user probably shouldn't be getting a client and manually constructing a Response object.\r\n\r\n@HonzaKral what do you think? If we agree on the interface I could implement that since I am probably going to do that for my project."}}