title: How to Get All Results from Elasticsearch in Python
body: <p>I am brand new to using Elasticsearch and I'm having an issue getting all results back when I run an Elasticsearch query through my Python script. My goal is to query an index ("my_index" below), take those results, and put them into a pandas DataFrame which goes through a Django app and eventually ends up in a Word document.</p>
  
  <p>My code is: </p>
  
  <pre><code>es = Elasticsearch()
  logs_index = "my_index"
  logs = es.search(index=logs_index,body=my_query)
  </code></pre>
  
  <p>and it tells me I have 72 hits, but then when I do: </p>
  
  <pre><code>df = logs['hits']['hits']
  len(df)
  </code></pre>
  
  <p>It says the length is only 10. I saw someone had a similar issue on <a href="https://github.com/elastic/elasticsearch-dsl-py/issues/737" rel="noreferrer">this question</a> but their solution did not work for me.</p>
  
  <pre><code>from elasticsearch import Elasticsearch
  from elasticsearch_dsl import Search
  es = Elasticsearch()
  logs_index = "my_index"
  search = Search(using=es)
  total = search.count()
  search = search[0:total]
  logs = es.search(index=logs_index,body=my_query)
  len(logs['hits']['hits'])
  </code></pre>
  
  <p>The len function still says I only have 10 results. What am I doing wrong, or what else can I do to get all 72 results back? </p>
  
  <p>ETA: I am aware that I can just add "size": 10000 to my query to stop it from truncating to just 10, but since the user will be entering their search query I need to find another way that isn't just in the search query.</p>