update-settings.asciidoc 3.8 KB

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