Get Data in CSV or Excel format from Elastic Search

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 ?

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

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" -H 'Content-Type: application/json' -d'{ "query": { "match": { "userId": "100" } }}'

Is it correct ??

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