Home > OS >  Write elasticsearch data in json file
Write elasticsearch data in json file

Time:04-30

I have 3 node elasticsearch cluster and I put data in index name pp_index in json format. I want to read that data and write in json file.

I can read data from below command but how can I write that data in json file

   curl -H 'Content-Type: application/json' -X GET http://localhost:9200/pp_index/_search?pretty

CodePudding user response:

You can use curl -o parameter to write output to the file like below:

curl -H 'Content-Type: application/json' -X GET http://localhost:9200/pp_index/_search?pretty -o myfile.json

But above search API will return only top 10 document from your index as you are not passing size param. If you need more data you can set size param value and it support max 10000.

http://localhost:9200/pp_index/_search?size=10000

I will suggest to use Java or Python elasticsearch client as you can get all the data from index and export it using client.

  • Related