update-settings.asciidoc 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. [[indices-update-settings]]
  2. == Update Indices Settings
  3. Change specific index level settings in real time.
  4. The REST endpoint is `/_settings` (to update all indices) or
  5. `{index}/_settings` to update one (or more) indices settings.
  6. The body of the request includes the updated settings, for example:
  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. To reset a setting back to the default value, use `null`. For example:
  19. [source,js]
  20. --------------------------------------------------
  21. PUT /twitter/_settings
  22. {
  23. "index" : {
  24. "refresh_interval" : null
  25. }
  26. }
  27. --------------------------------------------------
  28. // CONSOLE
  29. // TEST[setup:twitter]
  30. The list of per-index settings which can be updated dynamically on live
  31. indices can be found in <<index-modules>>.
  32. To preserve existing settings from being updated, the `preserve_existing`
  33. request parameter can be set to `true`.
  34. [float]
  35. [[bulk]]
  36. === Bulk Indexing Usage
  37. For example, the update settings API can be used to dynamically change
  38. the index from being more performant for bulk indexing, and then move it
  39. to more real time indexing state. Before the bulk indexing is started,
  40. use:
  41. [source,js]
  42. --------------------------------------------------
  43. PUT /twitter/_settings
  44. {
  45. "index" : {
  46. "refresh_interval" : "-1"
  47. }
  48. }
  49. --------------------------------------------------
  50. // CONSOLE
  51. // TEST[setup:twitter]
  52. (Another optimization option is to start the index without any replicas,
  53. and only later adding them, but that really depends on the use case).
  54. Then, once bulk indexing is done, the settings can be updated (back to
  55. the defaults for example):
  56. [source,js]
  57. --------------------------------------------------
  58. PUT /twitter/_settings
  59. {
  60. "index" : {
  61. "refresh_interval" : "1s"
  62. }
  63. }
  64. --------------------------------------------------
  65. // CONSOLE
  66. // TEST[continued]
  67. And, a force merge should be called:
  68. [source,js]
  69. --------------------------------------------------
  70. POST /twitter/_forcemerge?max_num_segments=5
  71. --------------------------------------------------
  72. // CONSOLE
  73. // TEST[continued]
  74. [float]
  75. [[update-settings-analysis]]
  76. === Updating Index Analysis
  77. It is also possible to define new <<analysis,analyzers>> for the index.
  78. But it is required to <<indices-open-close,close>> the index
  79. first and <<indices-open-close,open>> it after the changes are made.
  80. For example if `content` analyzer hasn't been defined on `myindex` yet
  81. you can use the following commands to add it:
  82. [source,js]
  83. --------------------------------------------------
  84. POST /twitter/_close
  85. PUT /twitter/_settings
  86. {
  87. "analysis" : {
  88. "analyzer":{
  89. "content":{
  90. "type":"custom",
  91. "tokenizer":"whitespace"
  92. }
  93. }
  94. }
  95. }
  96. POST /twitter/_open
  97. --------------------------------------------------
  98. // CONSOLE
  99. // TEST[setup:twitter]