1

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

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.