update-settings.asciidoc 3.5 KB

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