Index settings are those settings that apply to a single index. Such settings will start with index.
. The exception to that rule is number_of_shards
and number_of_replicas
, which also exist in the form of index.number_of_shards
and index.number_of_replicas
.
As the name suggests, index-level settings apply to a single index. Some settings must be applied at creation time because they cannot be changed dynamically, such as the index.number_of_shards
setting, which controls the number of primary shards for the index.
PUT /my_index
{
"settings": {
"index.number_of_shards": 1,
"index.number_of_replicas": 1
}
}
or, in a more concise format, you can combine key prefixes at each .
:
PUT /my_index
{
"settings": {
"index": {
"number_of_shards": 1,
"number_of_replicas": 1
}
}
}
The above examples will create an index with the supplied settings. You can dynamically change settings per-index by using the index _settings
endpoint. For example, here we dynamically change the slowlog settings for only the warn level:
PUT /my_index/_settings
{
"index": {
"indexing.slowlog.threshold.index.warn": "1s",
"search.slowlog.threshold": {
"fetch.warn": "500ms",
"query.warn": "2s"
}
}
}
Warning: Elasticsearch 1.x and 2.x did not very strictly validate index-level setting names. If you had a typo, or simply made up a setting, then it would blindly accept it, but otherwise ignore it. Elasticsearch 5.x strictly validates setting names and it will reject any attempt to apply index settings with an unknown setting(s) (due to typo or missing plugin). Both statements apply to dynamically changing index settings and at creation time.