title: How to export the whole elasticsearch index data into a csv file
body: <p>I am planning to fetch all the rows in an elastic search index, and then store the rows as a CSV file. However, most methods that I have tried, ended up giving me size limit errors.</p>
  <pre><code>curl -k -u username:password -XGET &quot;https://xx.xx.xx.xx:xxxx/foo-index/_search?scroll=10m&quot; 
  -H 'Content-Type: application/json' 
  -d'{ &quot;from&quot;: 0, &quot;size&quot;: 933963, &quot;query&quot; : { &quot;match_all&quot; : {} },  &quot;track_total_hits&quot;: true,  &quot;_source&quot;: [&quot;foo_id&quot;]}'
  </code></pre>
  <p>The error displayed is:</p>
  <pre><code>{&quot;error&quot;:{&quot;root_cause&quot;:[{&quot;type&quot;:&quot;illegal_argument_exception&quot;,&quot;reason&quot;:&quot;Batch size is too large, size must be less than or equal to: [10000] but was [933963]. Scroll batch sizes cost as much memory as result windows so they are controlled by the [index.max_result_window] index level setting.&quot;}],&quot;type&quot;:&quot;search_phase_execution_exception&quot;,&quot;reason&quot;:&quot;all shards failed&quot;,&quot;phase&quot;:&quot;query&quot;,&quot;grouped&quot;:true,&quot;failed_shards&quot;:[{&quot;shard&quot;:0,&quot;index&quot;:&quot;foo-index&quot;,&quot;node&quot;:&quot;k0OUtLDFRye4gIXGKCKLmQ&quot;,&quot;reason&quot;:{&quot;type&quot;:&quot;illegal_argument_exception&quot;,&quot;reason&quot;:&quot;Batch size is too large, size must be less than or equal to: [10000] but was [933963]. Scroll batch sizes cost as much memory as result windows so they are controlled by the [index.max_result_window] index level setting.&quot;}}]
  </code></pre>
  <p>The thing is that there is no way I can reduce the size because I need to get the whole content inside the index.</p>