Skip to content

Instantly share code, notes, and snippets.

@kszarek
Created August 23, 2016 21:42
Show Gist options
  • Save kszarek/868c5d8d1dd61e876d7913e4e3e472bb to your computer and use it in GitHub Desktop.
Save kszarek/868c5d8d1dd61e876d7913e4e3e472bb to your computer and use it in GitHub Desktop.
Remove document type from ES index
#!/bin/bash
set -e
type=application
month=2016.02
for index in $(curl -s 'localhost:9200/_cat/shards'|grep $month|awk '{print $1}'|sort|uniq)
do
echo
echo "Cleaning $index"
echo
curl -XDELETE http://localhost:9200/${index}/${type}
curl -XPOST http://localhost:9200/${index}/_optimize?only_expunge_deletes=true
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment