update-settings.asciidoc 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. The body
  6. of the request includes the updated settings, for example:
  7. [source,js]
  8. --------------------------------------------------
  9. {
  10. "index" : {
  11. "number_of_replicas" : 4
  12. }
  13. }
  14. --------------------------------------------------
  15. The above will change the number of replicas to 4 from the current
  16. number of replicas. Here is a curl example:
  17. [source,js]
  18. --------------------------------------------------
  19. curl -XPUT 'localhost:9200/my_index/_settings' -d '
  20. {
  21. "index" : {
  22. "number_of_replicas" : 4
  23. }
  24. }'
  25. --------------------------------------------------
  26. The list of per-index settings which can be updated dynamically on live
  27. indices can be found in <<index-modules>>.
  28. [float]
  29. [[bulk]]
  30. === Bulk Indexing Usage
  31. For example, the update settings API can be used to dynamically change
  32. the index from being more performant for bulk indexing, and then move it
  33. to more real time indexing state. Before the bulk indexing is started,
  34. use:
  35. [source,js]
  36. --------------------------------------------------
  37. curl -XPUT localhost:9200/test/_settings -d '{
  38. "index" : {
  39. "refresh_interval" : "-1"
  40. } }'
  41. --------------------------------------------------
  42. (Another optimization option is to start the index without any replicas,
  43. and only later adding them, but that really depends on the use case).
  44. Then, once bulk indexing is done, the settings can be updated (back to
  45. the defaults for example):
  46. [source,js]
  47. --------------------------------------------------
  48. curl -XPUT localhost:9200/test/_settings -d '{
  49. "index" : {
  50. "refresh_interval" : "1s"
  51. } }'
  52. --------------------------------------------------
  53. And, an optimize should be called:
  54. [source,js]
  55. --------------------------------------------------
  56. curl -XPOST 'http://localhost:9200/test/_optimize?max_num_segments=5'
  57. --------------------------------------------------
  58. [float]
  59. [[update-settings-analysis]]
  60. === Updating Index Analysis
  61. It is also possible to define new <<analysis,analyzers>> for the index.
  62. But it is required to <<indices-open-close,close>> the index
  63. first and <<indices-open-close,open>> it after the changes are made.
  64. For example if `content` analyzer hasn't been defined on `myindex` yet
  65. you can use the following commands to add it:
  66. [source,js]
  67. --------------------------------------------------
  68. curl -XPOST 'localhost:9200/myindex/_close'
  69. curl -XPUT 'localhost:9200/myindex/_settings' -d '{
  70. "analysis" : {
  71. "analyzer":{
  72. "content":{
  73. "type":"custom",
  74. "tokenizer":"whitespace"
  75. }
  76. }
  77. }
  78. }'
  79. curl -XPOST 'localhost:9200/myindex/_open'
  80. --------------------------------------------------