Skip to content

Instantly share code, notes, and snippets.

@shaharmor
Last active August 29, 2015 14:26
Show Gist options
  • Save shaharmor/b51a9297337133efab5f to your computer and use it in GitHub Desktop.
Save shaharmor/b51a9297337133efab5f to your computer and use it in GitHub Desktop.
Elasticsearch scripts
curl -XPUT localhost:9200/logstash-YYYY.MM.DD/_settings -d '{ "index.cache.query.enable": true }'
YEAR_START=2015
YEAR_END=2015
MONTH_START=1
MONTH_END=12
DAY_START=1
DAY_END=31
for year in $(seq -f "%04g" $YEAR_START $YEAR_END)
do
for month in $(seq -f "%02g" $MONTH_START $MONTH_END)
do
for day in $(seq -f "%02g" $DAY_START $DAY_END)
do
echo "$year.$month.$day"
done
done
done
curl -XPOST "localhost:9200/logstash-YYYY.MM.DD/_optimize?max_num_segments=1"
# beofre using this script you must install the reindex module from https://github.com/codelibs/elasticsearch-reindexing
# using $ES_HOME/bin/plugin --install org.codelibs/elasticsearch-reindexing/1.7.0
curl -XPOST "localhost:9200/logstash-YYYY.MM.DD/_reindex/logstash-YYYY.MM.DD-old/?wait_for_completion=true"
curl -XDELETE "localhost:9200/logstash-YYYY.MM.DD/"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment