Exporting Full Elasticsearch Index as a JSON File

Petr Filipchyk
Clear Blue Design
Published in
2 min readJun 3, 2022

--

Because Elasticsearch Dev Tools and standard Elasticsearch search API limit the number of records to 10,000, the simplest way to export all of the index data as JSON file is to use the elasticsearch-dump tool: https://github.com/elasticsearch-dump/elasticsearch-dump.

Underneath, it’s probably using either PIT (point-in-time) or scroll API, though why bother with those when someone created a great tool that does it all.

So, let’s see how it’s done in a couple simple steps.

Install the elasticsearch-dump tool:

npm install -g elasticdump

Run the tool to export your index:

elasticdump \
--input https://<ES_URL>:<ES_PORT>/<INDEX_NAME> \
--output es-exported-index.json \
--type=data \
--size=-1 \
--headers='{"Authorization": "Basic <AUTH_KEY>"}'

Parameters:

  • <ES_URL> is the base URL for your ES server (e.g. myesserver.es.us-east-1.aws.found.io)
  • <ES_PORT> is the port number for your ES server (e.g. 9243)
  • <INDEX_NAME> is the name of the index to export (e.g. providers)
  • size” parameter with value “-1” tells the tool to export all data; use smaller value (e.g. 100) to test with
  • headers” parameter is needed only if your index in not publicly accessible to you from your machine. You can generate the basic authentication AUTH_KEY inside your Elasticsearch Cloud or inside your custom ES installation.

That’s it — short, simple and sweet.

--

--