# Get all ids with Python

**URL:** https://discuss.elastic.co/t/get-all-ids-with-python/344689
**Category:** Elasticsearch
**Created:** [October 9, 2023, 6:44pm UTC](https://discuss.elastic.co/t/get-all-ids-with-python/344689 "2023-10-09T18:44:48Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![marc.schwarzschild](https://avatars.discourse-cdn.com/v4/letter/m/5f9b8f/32.png) [@marc.schwarzschild](https://discuss.elastic.co/u/marc.schwarzschild)
#### Post date: [October 9, 2023, 6:44pm UTC](https://discuss.elastic.co/t/get-all-ids-with-python/344689/1 "2023-10-09T18:44:48Z")

</div>

Hi,  
I'd like to use the `elastic_enterprise_search.AppSearch` package to get all our document ids. I have tried many things and always hit the 10k result limit. I understand that "scrolling" may be the solution but have not seen it work. This is last thing I tried:

```auto
es = AppSearch(APP_SEARCH_API_HOST, bearer_auth=APP_SEARCH_API_KEY)
body = {"size": 100, "scroll": "1m"}
scroll_response = es.search(engine_name=ENGINE, body=body)
document_ids = []
hits = scroll_response.get("results", [])
for hit in hits:
    document_ids.append(hit["_id"])

```

Please advise.  
Thank you.

---

<div class="post-metadata">

### Author: ![azizim](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/azizim/32/127005_2.png) [@azizim](https://discuss.elastic.co/u/azizim)
#### Post date: [October 27, 2023, 9:51pm UTC](https://discuss.elastic.co/t/get-all-ids-with-python/344689/2 "2023-10-27T21:51:21Z")

</div>

Have you used "from" keyword:  
Example

```auto

i = 0
document_ids = []
while i<100000:
   body = { "from": i }
   scroll_response = es.search(engine_name=ENGINE, body=body)
   i+=10000
   for hit in hits:
          document_ids.append(hit["_id"])

```

---

<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: [November 24, 2023, 9:51pm UTC](https://discuss.elastic.co/t/get-all-ids-with-python/344689/3 "2023-11-24T21:51:27Z")

</div>

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