Will & Skill Developers

Will & Skill Developers


Thoughts, snippets and ideas from the team at Will & Skill AB, Stockholm.

Faisal M
Author

“The mind is not a vessel to be filled, but a fire to be kindled.” ― Plutarch

Share


Tags


avrt

How to extract/restore bulk data from/to an ElasticSearch index

Faisal MFaisal M

Start by installing the package elasticdump from NPM

npm install elasticdump -g

NOTE: I installed the package globally in order to use it on several projects. You can install it locally by running npm install elasticdump.

Make sure that Your ElasticSearch instance up and running

curl http://localhost:9200

If You now run the command below You should be able to see the indexes that You have in Your ES server.

curl http://localhost:9200/_cat/indices

The command above should return something like this

yellow open sweden   zrRXFpsIRgSWejhNOwq1pA 5 1 51086 0 116mb 116mb
yellow open norway   wYyI8O6JR7a-E478Jh16aA 5 1     0 0 1.2kb 1.2kb
yellow open finland  SJmneHYZSuu1hiVhoAscaA 5 1     0 0 1.2kb 1.2kb
yellow open denmark  tZM3TJi6QEalmqWolw0JKg 5 1     0 0 1.2kb 1.2kb

As You can see, the names of our indices is denmark , finland, norway, sweden.

If we want to extract all the mapping or the data that resides in the sweden index we can run the command stated below.

Get the mapping from the index

elasticdump \
  --input=http://localhost:9200/sweden \
  --output=./es-mapping-sweden-20191018-1400.json \
  --type=mapping

Get the data from the index

elasticdump \
  --input=http://localhost:9200/sweden \
  --output=./es-data-sweden-20191018-1400.json \
  --type=data

Load data into an index

elasticdump \
  --input=./es-data-sweden-20191018-1400.json \
  --output=http://localhost:9200/sweden \
  --type=data

Read more about elasticdump here

Faisal M
Author

Faisal M

“The mind is not a vessel to be filled, but a fire to be kindled.” ― Plutarch

View Comments