The settings endpoint, written as _settings, reads an index’s configuration and changes settings that Elasticsearch permits. Create an index with essential settings up front, then adjust dynamic settings while the index remains operational. section 6.2.3
Use the endpoint according to the kind of setting you need to manage:
- Set static properties, such as primary shard count or compression codec, during index creation; changing them later requires closing or recreating the index. section 6.2.3
- Change dynamic properties, such as replica count, write blocking, or refresh interval, on a live index. section 6.2.3
- Fetch one index, several named indexes, wildcard-matched indexes, or a single setting attribute. section 6.2.3
Tune refresh during a migration
PUT movies/_settings { "index": { "refresh_interval": "60s" } } A longer interval reduces refresh activity while documents are indexed. Setting refresh_interval to -1 disables refresh temporarily; after the migration, POST movies/_refresh makes accumulated documents searchable. The setting is dynamic, so this change can be made on a live index. section 5.1.3
Listing 6.5 Creating an index with custom settings
PUT cars_with_custom_settings #1
{
"settings":{ #2
"number_of_shards":3, #3
"number_of_replicas":5, #4
"codec": "best_compression", #5
"max_script_fields":128, #6
"refresh_interval": "60s" #7
}
}
A complete creation request shows how shard count, replicas, compression, script-field limits, and refresh interval are supplied together under settings. section 6.2.3
Change replicas or block writes
PUT cars_with_custom_settings/_settings { "settings": { "number_of_replicas": 2 } } For an index operation such as splitting, use the same endpoint to make the source read-only by setting index.blocks.write to true before invoking the split API. section 6.8.1
