elasticsearch/elasticsearch — pull request #8819 by dakrone (2014-12-08 11:40:49+00:00)
Title: Add index.data_path and index.data_template settings

This allows specifying the path an index will be as well as the layout
of the folder for each individual shard.

`index.data_path` and `index.data_template` are both specified in the
settings when creating an index, and can not be dynamically changed.

`index.data_path` is the path to the base directory for the index.

`index.data_template` is a mustache template that will be used when
resolving the path for an index or translog. It currently supports three
injected variables:

`{{index_name}}` - the name of the index
`{{node_id}}` - numeric id of the node
`{{shard_num}}` - shard number

An example request would look like:

```json
POST /myindex
{
"settings": {
"number_of_shards": 2,
"data_path": "/tmp/myindex",
"data_template": "i_{{index_name}}/{{node_id}}/shard_{{shard_num}}"
}
}
```

And would put data in /tmp/myindex/i_myindex/0/shard_0 and
/tmp/myindex/i_myindex/0/shard_1

I found that the `NodeEnvironment` abstraction works well for index-specific
data paths, and passing the index settings in to the various methods gives
us more flexibility in the future with regard to adding any other environment-
specific settings.