update-settings.asciidoc 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. [[indices-update-settings]]
  2. === Update index settings API
  3. ++++
  4. <titleabbrev>Update index settings</titleabbrev>
  5. ++++
  6. Changes an <<index-modules-settings,index setting>> in real time.
  7. [source,console]
  8. --------------------------------------------------
  9. PUT /twitter/_settings
  10. {
  11. "index" : {
  12. "number_of_replicas" : 2
  13. }
  14. }
  15. --------------------------------------------------
  16. // TEST[setup:twitter]
  17. [[update-index-settings-api-request]]
  18. ==== {api-request-title}
  19. `PUT /<index>/_settings`
  20. [[update-index-settings-api-path-params]]
  21. ==== {api-path-parms-title}
  22. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=index]
  23. +
  24. To update a setting for all indices,
  25. use `_all` or exclude this parameter.
  26. [[update-index-settings-api-query-params]]
  27. ==== {api-query-parms-title}
  28. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=allow-no-indices]
  29. +
  30. Defaults to `false`.
  31. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=expand-wildcards]
  32. +
  33. Defaults to `open`.
  34. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=flat-settings]
  35. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=index-ignore-unavailable]
  36. `preserve_existing`::
  37. (Optional, boolean) If `true`, existing index settings remain unchanged.
  38. Defaults to `false`.
  39. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=timeoutparms]
  40. [[update-index-settings-api-request-body]]
  41. ==== {api-request-body-title}
  42. `settings`::
  43. (Optional, <<index-modules-settings,index setting object>>) Configuration
  44. options for the index. See <<index-modules-settings>>.
  45. [[update-index-settings-api-example]]
  46. ==== {api-examples-title}
  47. [[reset-index-setting]]
  48. ===== Reset an index setting
  49. To revert a setting to the default value, use `null`. For example:
  50. [source,console]
  51. --------------------------------------------------
  52. PUT /twitter/_settings
  53. {
  54. "index" : {
  55. "refresh_interval" : null
  56. }
  57. }
  58. --------------------------------------------------
  59. // TEST[setup:twitter]
  60. The list of per-index settings which can be updated dynamically on live
  61. indices can be found in <<index-modules>>.
  62. To preserve existing settings from being updated, the `preserve_existing`
  63. request parameter can be set to `true`.
  64. [[bulk]]
  65. ===== Bulk indexing usage
  66. For example, the update settings API can be used to dynamically change
  67. the index from being more performant for bulk indexing, and then move it
  68. to more real time indexing state. Before the bulk indexing is started,
  69. use:
  70. [source,console]
  71. --------------------------------------------------
  72. PUT /twitter/_settings
  73. {
  74. "index" : {
  75. "refresh_interval" : "-1"
  76. }
  77. }
  78. --------------------------------------------------
  79. // TEST[setup:twitter]
  80. (Another optimization option is to start the index without any replicas,
  81. and only later adding them, but that really depends on the use case).
  82. Then, once bulk indexing is done, the settings can be updated (back to
  83. the defaults for example):
  84. [source,console]
  85. --------------------------------------------------
  86. PUT /twitter/_settings
  87. {
  88. "index" : {
  89. "refresh_interval" : "1s"
  90. }
  91. }
  92. --------------------------------------------------
  93. // TEST[continued]
  94. And, a force merge should be called:
  95. [source,console]
  96. --------------------------------------------------
  97. POST /twitter/_forcemerge?max_num_segments=5
  98. --------------------------------------------------
  99. // TEST[continued]
  100. [[update-settings-analysis]]
  101. ===== Update index analysis
  102. You can only define new analyzers on closed indices.
  103. To add an analyzer,
  104. you must close the index,
  105. define the analyzer,
  106. and reopen the index.
  107. For example,
  108. the following commands add the `content` analyzer to `myindex`:
  109. [source,console]
  110. --------------------------------------------------
  111. POST /twitter/_close
  112. PUT /twitter/_settings
  113. {
  114. "analysis" : {
  115. "analyzer":{
  116. "content":{
  117. "type":"custom",
  118. "tokenizer":"whitespace"
  119. }
  120. }
  121. }
  122. }
  123. POST /twitter/_open
  124. --------------------------------------------------
  125. // TEST[setup:twitter]