update-settings.asciidoc 3.6 KB

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