# Scroll api issue

**URL:** https://discuss.elastic.co/t/scroll-api-issue/180254
**Category:** Elasticsearch
**Created:** [May 8, 2019, 9:05pm UTC](https://discuss.elastic.co/t/scroll-api-issue/180254 "2019-05-08T21:05:36Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![iukea](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/iukea/32/49083_2.png) [@iukea](https://discuss.elastic.co/u/iukea)
#### Post date: [May 8, 2019, 9:05pm UTC](https://discuss.elastic.co/t/scroll-api-issue/180254/1 "2019-05-08T21:05:36Z")

</div>

Hello, I am trying to use the scroll API in Python, and i having an issue for it looping through my whole dataset.

I get about 100 results returned when there should be over 150k of them (I can see them in kibana)

attached is my code

```
res = helpers.scan(client = es, scroll = '2m', query = {
      "size": 10000,
        "query": {
          "match": {
            "type": {
              "query": "SSH-Telnet_Threats"
            }}}}, 
    index = "logstash-*")

# function to return hits from the elasticsearch query in res

def get_es_json(es_scan):
    for hits in es_scan:
        return hits

# iterate through results with defined number of results

def return_es_results(es_json_data, num_results):
    for i in range(num_results):
        data = get_es_json(es_json_data)
        print(data['_source']['geoip']['asn'])

return_es_results(res, 100)
```

---

<div class="post-metadata">

### Author: ![iukea](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/iukea/32/49083_2.png) [@iukea](https://discuss.elastic.co/u/iukea)
#### Post date: [May 8, 2019, 11:15pm UTC](https://discuss.elastic.co/t/scroll-api-issue/180254/2 "2019-05-08T23:15:40Z")

</div>

also posted here [https://stackoverflow.com/questions/56049910/elasticsearch-scroll-api-issue](https://stackoverflow.com/questions/56049910/elasticsearch-scroll-api-issue)

---

<div class="post-metadata">

### Author: ![gabriel\_tessier](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gabriel_tessier/32/27911_2.png) [@gabriel\_tessier](https://discuss.elastic.co/u/gabriel_tessier)
#### Post date: [May 9, 2019, 2:15am UTC](https://discuss.elastic.co/t/scroll-api-issue/180254/3 "2019-05-09T02:15:39Z")

</div>

I replied in stackoverflow.

In your call you asked for 100 results

```auto
return_es_results(res, 100)

```

So it's returning 100 results....  
you may want to paginate?  
if you use django there's some documentation here about pagination:  
[https://docs.djangoproject.com/en/2.2/topics/pagination/](https://docs.djangoproject.com/en/2.2/topics/pagination/)

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [June 6, 2019, 2:15am UTC](https://discuss.elastic.co/t/scroll-api-issue/180254/4 "2019-06-06T02:15:42Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
