# Get Data in CSV or Excel format from Elastic Search

**URL:** <https://discuss.elastic.co/t/get-data-in-csv-or-excel-format-from-elastic-search/224060>\
**Category:** Elasticsearch\
**Created:** [March 18, 2020, 9:39am UTC](https://discuss.elastic.co/t/get-data-in-csv-or-excel-format-from-elastic-search/224060 "2020-03-18T09:39:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rabii47](https://avatars.discourse-cdn.com/v4/letter/r/48db29/32.png) [@Rabii47](https://discuss.elastic.co/u/Rabii47)\
**Post date:** [March 18, 2020, 9:39am UTC](https://discuss.elastic.co/t/get-data-in-csv-or-excel-format-from-elastic-search/224060/1 "2020-03-18T09:39:22Z")

</div>

Hi, i am trying to get the data from ElasticSearch in my Spring Application in the format Excel or CSV.  
The size of my data is between 5000 and 10000 .  
What is the best way to accomplish that ?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 18, 2020, 9:58am UTC](https://discuss.elastic.co/t/get-data-in-csv-or-excel-format-from-elastic-search/224060/2 "2020-03-18T09:58:35Z")

</div>

If the size is super limited (under 10000 hits), you can just run a search query with `size=10000` and then read all the hits and generate whatever structure you want.

You can also look at this: [https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-rest-format.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-rest-format.html)

---

<div class="post-metadata">

**Author:** ![Rabii47](https://avatars.discourse-cdn.com/v4/letter/r/48db29/32.png) [@Rabii47](https://discuss.elastic.co/u/Rabii47)\
**Post date:** [March 19, 2020, 8:50am UTC](https://discuss.elastic.co/t/get-data-in-csv-or-excel-format-from-elastic-search/224060/3 "2020-03-19T08:50:58Z")

</div>

Thanks , but if i read all the 10000 hits , il will consume a lot of memory (using the 'for' loop or 'while')  
**I need an API to get me the resuly directly in the format XML or EXCEL .is there any ?**

I tried getting that with curl command , but my inputStream is empty .  
Here my curl command :

curl -XGET "[http://localhost:9100/myIndex/\_search](http://localhost:9100/myIndex/_search)" -H 'Content-Type: application/json' -d'{ "query": { "match": { "userId": "100" } }}'

Is it correct ??

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 19, 2020, 9:35am UTC](https://discuss.elastic.co/t/get-data-in-csv-or-excel-format-from-elastic-search/224060/4 "2020-03-19T09:35:09Z")

</div>

> [@Rabii47](#):
>
> I need an API to get me the resuly directly in the format XML or EXCEL .is there any ?

No. The supported formats with the SQL feature are listed in the link I shared.

---

<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:** [April 16, 2020, 9:39am UTC](https://discuss.elastic.co/t/get-data-in-csv-or-excel-format-from-elastic-search/224060/5 "2020-04-16T09:39:10Z")

</div>

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