update-settings.asciidoc 3.8 KB

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