Skip to content

Instantly share code, notes, and snippets.

@dcode
Last active October 7, 2016 17:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcode/7b3ae2f987408048363b34755acb2091 to your computer and use it in GitHub Desktop.
Save dcode/7b3ae2f987408048363b34755acb2091 to your computer and use it in GitHub Desktop.
Attempt to migrate data to old indexes. I need to do this because data types changed, but I don't want to lose the old data.
# Move index names from bro-YYYY.MM.DD to bro-v1-YYYY.MM.DD
for item in $(curl -s -n -XGET localhost:9200/_cat/indices | awk '/bro-/ { split($3,a,"-"); print a[2] }'); do
cat <<EOF | curl -s -n -XPOST localhost:9200/_reindex -d @- >/dev/null
{ "source": {"index": "bro-${item}"}, "dest": {"index": "bro.v1-${item}"} }
EOF
echo -e "\nCloned data from bro-${item} to bro.v1-${item}"
done
for item in $(curl -s -n -XGET localhost:9200/_cat/indices | awk '/bro-/ { print $3 }'); do
curl -s -n -XDELETE "localhost:9200/${item}";
echo -e "\n Delete ${item}";
echo -e "\nDeleted data from ${item}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment