update-settings.asciidoc 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. [[cluster-update-settings]]
  2. === Cluster update settings API
  3. ++++
  4. <titleabbrev>Cluster update settings</titleabbrev>
  5. ++++
  6. Updates cluster-wide settings.
  7. [[cluster-update-settings-api-request]]
  8. ==== {api-request-title}
  9. `PUT /_cluster/settings`
  10. [[cluster-update-settings-api-desc]]
  11. ==== {api-description-title}
  12. With specifications in the request body, this API call can update cluster
  13. settings. Updates to settings can be persistent, meaning they apply across
  14. restarts, or transient, where they don't survive a full cluster restart.
  15. You can reset persistent or transient settings by assigning a `null` value. If a
  16. transient setting is reset, the first one of these values that is defined is
  17. applied:
  18. * the persistent setting
  19. * the setting in the configuration file
  20. * the default value.
  21. The order of precedence for cluster settings is:
  22. 1. transient cluster settings
  23. 2. persistent cluster settings
  24. 3. settings in the `elasticsearch.yml` configuration file.
  25. It's best to set all cluster-wide settings with the `settings` API and use the
  26. `elasticsearch.yml` file only for local configurations. This way you can be sure that
  27. the setting is the same on all nodes. If, on the other hand, you define different
  28. settings on different nodes by accident using the configuration file, it is very
  29. difficult to notice these discrepancies.
  30. You can find the list of settings that you can dynamically update in
  31. <<modules,Modules>>.
  32. [[cluster-update-settings-api-query-params]]
  33. ==== {api-query-parms-title}
  34. include::{docdir}/rest-api/common-parms.asciidoc[tag=flat-settings]
  35. `include_defaults`::
  36. (Optional, boolean) If `true`, returns all default cluster settings.
  37. Defaults to `false`.
  38. include::{docdir}/rest-api/common-parms.asciidoc[tag=timeoutparms]
  39. [[cluster-update-settings-api-example]]
  40. ==== {api-examples-title}
  41. An example of a persistent update:
  42. [source,console]
  43. --------------------------------------------------
  44. PUT /_cluster/settings
  45. {
  46. "persistent" : {
  47. "indices.recovery.max_bytes_per_sec" : "50mb"
  48. }
  49. }
  50. --------------------------------------------------
  51. An example of a transient update:
  52. [source,console]
  53. --------------------------------------------------
  54. PUT /_cluster/settings?flat_settings=true
  55. {
  56. "transient" : {
  57. "indices.recovery.max_bytes_per_sec" : "20mb"
  58. }
  59. }
  60. --------------------------------------------------
  61. The response to an update returns the changed setting, as in this response to
  62. the transient example:
  63. [source,console-result]
  64. --------------------------------------------------
  65. {
  66. ...
  67. "persistent" : { },
  68. "transient" : {
  69. "indices.recovery.max_bytes_per_sec" : "20mb"
  70. }
  71. }
  72. --------------------------------------------------
  73. // TESTRESPONSE[s/\.\.\./"acknowledged": true,/]
  74. This example resets a setting:
  75. [source,console]
  76. --------------------------------------------------
  77. PUT /_cluster/settings
  78. {
  79. "transient" : {
  80. "indices.recovery.max_bytes_per_sec" : null
  81. }
  82. }
  83. --------------------------------------------------
  84. The response does not include settings that have been reset:
  85. [source,console-result]
  86. --------------------------------------------------
  87. {
  88. ...
  89. "persistent" : {},
  90. "transient" : {}
  91. }
  92. --------------------------------------------------
  93. // TESTRESPONSE[s/\.\.\./"acknowledged": true,/]
  94. You can also reset settings using wildcards. For example, to reset
  95. all dynamic `indices.recovery` settings:
  96. [source,console]
  97. --------------------------------------------------
  98. PUT /_cluster/settings
  99. {
  100. "transient" : {
  101. "indices.recovery.*" : null
  102. }
  103. }
  104. --------------------------------------------------