update-settings.asciidoc 2.6 KB

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