How to bulk create (export/import) indices in elasticsearch? How to bulk create (export/import) indices in elasticsearch? elasticsearch elasticsearch

How to bulk create (export/import) indices in elasticsearch?


With a single curl command you could create an index template that will trigger the index creation at the time the documents hit your ES 5.x cluster.

Basically, this single curl command will create an index template that will kick in for each new index created on-the-fly. You can then use the "reindex from remote" technique in order to move your documents from ES 1.x to ES 5.x and don't worry about index creation since the index template will take care of it.

curl -XPUT 'localhost:9200/_template/my_template' -H 'Content-Type: application/json' -d'{  "template": "*",  "settings": {     "index.refresh_interval" : -1,     "index.number_of_replicas" : 0  }}'


Was able to accomplish this with a formatted list of indices created via an index list fed through sed, then feeding that file through the following script:

#! /bin/bashwhile read some_index; docurl -XPUT "localhost:9200/$some_index?pretty" -d'{    "settings" : {        "index" : {            "refresh_interval" : -1,            "number_of_replicas" : 0        }    }}'sleep 1done <$1

If anyone can point me in the direction of any pre-existing mechanisms in Elasticsearch, though, please do.