# Can't updating index settings via /\_settings prior to index existance

**URL:** <https://discuss.elastic.co/t/cant-updating-index-settings-via--settings-prior-to-index-existance/56750>\
**Category:** Elasticsearch\
**Created:** [July 29, 2016, 4:14pm UTC](https://discuss.elastic.co/t/cant-updating-index-settings-via--settings-prior-to-index-existance/56750 "2016-07-29T16:14:42Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![hartfordfive](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hartfordfive/32/44794_2.png) [@hartfordfive](https://discuss.elastic.co/u/hartfordfive)\
**Post date:** [July 29, 2016, 4:14pm UTC](https://discuss.elastic.co/t/cant-updating-index-settings-via--settings-prior-to-index-existance/56750/1 "2016-07-29T16:14:42Z")

</div>

From my understanding `index.number_of_replicas` can be set in the elsaticsearch.yml config yet it seems I can't update it via the `/_settings` API endpoint unless the index already exists:

```auto
# curl -XPUT http://127.0.01:9200/_settings -d '{"index.refresh_interval":"15s","index.number_of_replicas":1}'

{"error":{"root_cause":[{"type":"index_not_found_exception","reason":"no such index","resource.type":"index_expression","resource.id":"_all"}],"type":"index_not_found_exception","reason":"no such index","resource.type":"index_expression","resource.id":"_all"},"status":404}

# curl -XPOST http://127.0.0.1:9200/test/test -d '{"name": "John", "title": "Mr", "age": 36}'

{"_index":"test","_type":"test","_id":"AVY3Yy-0zDeC1CeGorHC","_version":1,"_shards":{"total":1,"successful":1,"failed":0},"created":true}

# curl -XPUT http://127.0.0.1:9200/_settings -d '{"index.refresh_interval":"15s","index.number_of_replicas":1}'

{"acknowledged":true}

```

The [documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules.html#dynamic-index-settings) for the `/_settings` API endpoint doesn't indicate this limitation. Considering this can be set in the elasticsearch.yml config (thus causing it to be applied before any indices exists) would it be reasonable to assume that it should be possible to apply global index settings via API prior to any index being created?

Thanks!

---

<div class="post-metadata">

**Author:** ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)\
**Post date:** [July 29, 2016, 5:16pm UTC](https://discuss.elastic.co/t/cant-updating-index-settings-via--settings-prior-to-index-existance/56750/2 "2016-07-29T17:16:43Z")

</div>

Yep, that default is not dynamically updateable. But more importantly, the ability to even specify `index.number_of_replicas` in the elasticsearch.yml has been removed entirely in 5.0. So the short answer is: "don't worry about it, since it's going away soon" 🙂

Basically, being able to specify that default in a static config is a bad thing and we yanked it. The elasticsearch.yml configs are supposed to be for node-level configuration. Something like `index.number_of_replicas` is really an index-level parameter, and has ramifications based on which node becomes master, etc.

For example, what happens if the value is configured inconsistently across the nodes, and different nodes become master at different times? The default for the cluster would change.

There are more details about it here: [https://github.com/elastic/elasticsearch/issues/18073#issuecomment-229579221](https://github.com/elastic/elasticsearch/issues/18073#issuecomment-229579221)

If you want to update all the indices at once, you can use a wildcard:

```auto
curl -XPUT http://127.0.01:9200/*/_settings {...}
or
curl -XPUT http://127.0.01:9200/_all/_settings {...}

```

And if you want to set a default, [index templates](https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html) are a much better option than the static config in elasticsearch.yml

---

<div class="post-metadata">

**Author:** ![hartfordfive](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hartfordfive/32/44794_2.png) [@hartfordfive](https://discuss.elastic.co/u/hartfordfive)\
**Post date:** [July 29, 2016, 5:59pm UTC](https://discuss.elastic.co/t/cant-updating-index-settings-via--settings-prior-to-index-existance/56750/3 "2016-07-29T17:59:45Z")

</div>

Thanks for the clarification on that! I do realize that you can set these  
default settings within an index template, although I was curious to know  
as to why I can't just set it via the `index.number_of_replicas` via the  
`/_settings` API even before any indices exist? Considering that the index  
templates would technically be set prior to any index being created, I  
don't see what the difference is when it comes to setting it via the  
/\_settings endpoint?

---

<div class="post-metadata">

**Author:** ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)\
**Post date:** [July 29, 2016, 6:04pm UTC](https://discuss.elastic.co/t/cant-updating-index-settings-via--settings-prior-to-index-existance/56750/4 "2016-07-29T18:04:34Z")

</div>

Not really a good reason to be honest. Just historical legacy / cruft. It's not technically a cluster-level setting based on how it works, so you can't set it dynamically via `/_cluster/settings`. It's technically an index-level setting... but you can only update index-level settings through the API on an actual, existing index. Which is why you cannot set it before the index is created.

So it occupies this bizzaro role of being an index-level-but-also-cluster-level setting, which happens to only be configurable via the static config.

It really was just a hacky thing put in place a loooong time ago, which didn't follow the normal semantics of how settings should work. Which is why it's a bit of a special snowflake, and also why it's been removed 🙂

---

<div class="post-metadata">

**Author:** ![hartfordfive](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hartfordfive/32/44794_2.png) [@hartfordfive](https://discuss.elastic.co/u/hartfordfive)\
**Post date:** [July 29, 2016, 6:16pm UTC](https://discuss.elastic.co/t/cant-updating-index-settings-via--settings-prior-to-index-existance/56750/5 "2016-07-29T18:16:28Z")

</div>

Ok, this makes more sense now. Thanks again for the clarification.

---

<div class="post-metadata">

**Author:** ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)\
**Post date:** [July 29, 2016, 6:21pm UTC](https://discuss.elastic.co/t/cant-updating-index-settings-via--settings-prior-to-index-existance/56750/6 "2016-07-29T18:21:05Z")

</div>

Sure, no problem! It's definitely an odd duck, you weren't wrong in thinking its behavior strange 🙂

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 10:31pm UTC](https://discuss.elastic.co/t/cant-updating-index-settings-via--settings-prior-to-index-existance/56750/7 "2017-07-05T22:31:41Z")

</div>


