Skip to content

Instantly share code, notes, and snippets.

@aterreno
Created November 4, 2013 16:21
Show Gist options
  • Save aterreno/7305098 to your computer and use it in GitHub Desktop.
Save aterreno/7305098 to your computer and use it in GitHub Desktop.
Script to migrate elastic search index mappings between one host and another one
#!/bin/bash
SOURCE_URI='http://10.251.76.43:9200'
DEST_URI='http://localhost:9200'
declare -a indexes=(gallery linklist module pageversion poll standardmodule styles video)
echo "Getting mappings from: $SOURCE_URI"
for index in ${indexes[@]}
do
echo "Exporting: $index"
curl -XGET "$SOURCE_URI/$index/$index/_mapping" > $index".json"
done
echo "Recreating mappings in: $DEST_URI"
for index in ${indexes[@]}
do
echo "Creating: $index"
curl -XPUT "$DEST_URI/$index/"
curl -XPUT "$DEST_URI/$index/$index/_mapping" -d @"$index.json"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment