Skip to content

Instantly share code, notes, and snippets.

@karussell
Created November 12, 2012 13:11
Show Gist options
  • Select an option

  • Save karussell/4059320 to your computer and use it in GitHub Desktop.

Select an option

Save karussell/4059320 to your computer and use it in GitHub Desktop.
A script for the rolling index plugin. To make it easier to be called from cron
# install the roll plugin for every server
# https://github.com/karussell/elasticsearch-rollindex/
# call this script ala roll.sh <indexPrefix> <type> <numberOfRemainingIndices>
indexprefix=$1
type=$2
roll=$3
SRC=
host=localhost:9200
# grab the mapping for 'type' from somewhere
MAP_PATH=$SRC"path/to/$type.json"
mappings=$(cat $MAP_PATH)
echo ""
echo `date`
content='{
"settings" : {
"number_of_shards" : 3,
"number_of_replicas": 1
},
"mappings" : '$mappings'
}'
echo $content
curl -XPUT "$host/_rollindex?indexPrefix=$indexprefix&searchIndices=$roll&rollIndices=$roll" -d "$content"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment