Last Updated: February 25, 2016
·
496
· der_do

ElasticSearch: Change index settings after their creation.

Foolish me! I created my indices in #elasticsearch (ES) with wrong analyzers/schema. Unfortunatly, ES does not let me change those online. Alas! I have bazzilions of documents already.

Lo! Help is on its way! With a little help from the excellent #knappsack plugin [1] for ES. It enables me to export everything, a certain index or any type. It can also import those back.

Off we go:

  1. Ensure that ES runs on another port

  2. curl -XPOST es:9900/_export?target=/tmp/all.tar.gz #sure, everything

  3. curl -XDELETE es:9900/_all #DELETE that crap

  4. curl -XPUT 'es:9900/_template/mytemplate' -d '...fancy new template def...' #ref [2]

  5. curl -XPOST es:9900/_import?target=/tmp/all #Reimport the now great crap (yes,
    the .tar.gz must not be there)

  6. Reconfigure ES to regular port

Nifty!

[1] https://github.com/jprante/elasticsearch-knapsack

[2] http://www.elasticsearch.org/guide/reference/api/admin-indices-templates/