# How to export an entire Elastic Search index to a csv file

**URL:** <https://discuss.elastic.co/t/how-to-export-an-entire-elastic-search-index-to-a-csv-file/296655>\
**Category:** Elasticsearch\
**Created:** [February 8, 2022, 7:58pm UTC](https://discuss.elastic.co/t/how-to-export-an-entire-elastic-search-index-to-a-csv-file/296655 "2022-02-08T19:58:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mwalk](https://avatars.discourse-cdn.com/v4/letter/m/fbc32d/32.png) [@mwalk](https://discuss.elastic.co/u/mwalk)\
**Post date:** [February 8, 2022, 7:58pm UTC](https://discuss.elastic.co/t/how-to-export-an-entire-elastic-search-index-to-a-csv-file/296655/1 "2022-02-08T19:58:54Z")

</div>

Hello,

We have an Elasticsearch index that has approximately 1 million records in it.  
We'd like to export only two fields from it, and ID (int) and a Value (string) for auditing purposes.

We've tried using es2csv, but it doesn't appear to work.  
What is the simplest way to export data from ES, a whole index, all rows?  
If there is a template Python example or something like that (or an out of the box method), we're interested, thanks!

---

<div class="post-metadata">

**Author:** ![aaron-nimocks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aaron-nimocks/32/73965_2.png) [@aaron-nimocks](https://discuss.elastic.co/u/aaron-nimocks)\
**Post date:** [February 8, 2022, 8:15pm UTC](https://discuss.elastic.co/t/how-to-export-an-entire-elastic-search-index-to-a-csv-file/296655/2 "2022-02-08T20:15:32Z")

</div>

Out of box method could be to use Logstash.

Input - [Read index from index](https://www.elastic.co/guide/en/logstash/current/plugins-inputs-elasticsearch.html) and use DSL query to only get the 2 fields needed  
Output - [CSV](https://www.elastic.co/guide/en/logstash/current/plugins-outputs-csv.html)

May need a [CSV Filter](https://www.elastic.co/guide/en/logstash/current/plugins-filters-csv.html), not sure if the output can convert or not.

---

<div class="post-metadata">

**Author:** ![mwalk](https://avatars.discourse-cdn.com/v4/letter/m/fbc32d/32.png) [@mwalk](https://discuss.elastic.co/u/mwalk)\
**Post date:** [February 8, 2022, 10:47pm UTC](https://discuss.elastic.co/t/how-to-export-an-entire-elastic-search-index-to-a-csv-file/296655/3 "2022-02-08T22:47:49Z")

</div>

Thank you Aaron!

Sorry, I'm not sure if you're pointing to multiple methods or just one.  
Are you saying to use Logstash with Elastic Dump or either/or?"

I read documentation about Elastic Dump, but wasn't sure if it automatically polls the whole index and downloads it to the specified output.

---

<div class="post-metadata">

**Author:** ![aaron-nimocks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aaron-nimocks/32/73965_2.png) [@aaron-nimocks](https://discuss.elastic.co/u/aaron-nimocks)\
**Post date:** [February 8, 2022, 10:51pm UTC](https://discuss.elastic.co/t/how-to-export-an-entire-elastic-search-index-to-a-csv-file/296655/4 "2022-02-08T22:51:22Z")

</div>

Just 1 method using [Logstash](https://www.elastic.co/guide/en/logstash/current/pipeline.html). Not sure what Elastic Dump is.

Logstash will essentially read your entire index of 1 million records and write it to disk in CSV format. The links in my post above are which plugins to use but I would start reading my first link about Logstash first.

---

<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:** [March 8, 2022, 10:52pm UTC](https://discuss.elastic.co/t/how-to-export-an-entire-elastic-search-index-to-a-csv-file/296655/5 "2022-03-08T22:52:14Z")

</div>

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