put_settings.asciidoc 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. [[java-rest-high-indices-put-settings]]
  2. === Update Indices Settings API
  3. The Update Indices Settings API allows to change specific index level settings.
  4. [[java-rest-high-indices-put-settings-request]]
  5. ==== Update Indices Settings Request
  6. An `UpdateSettingsRequest`:
  7. ["source","java",subs="attributes,callouts,macros"]
  8. --------------------------------------------------
  9. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[put-settings-request]
  10. --------------------------------------------------
  11. <1> Update settings for one index
  12. <2> Update settings for multiple indices
  13. <3> Update settings for all indices
  14. ==== Indices Settings
  15. At least one setting to be updated must be provided:
  16. ["source","java",subs="attributes,callouts,macros"]
  17. --------------------------------------------------
  18. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[put-settings-create-settings]
  19. --------------------------------------------------
  20. <1> Sets the index settings to be applied
  21. ==== Providing the Settings
  22. The settings to be applied can be provided in different ways:
  23. ["source","java",subs="attributes,callouts,macros"]
  24. --------------------------------------------------
  25. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[put-settings-create-settings]
  26. --------------------------------------------------
  27. <1> Creates a setting as `Settings`
  28. ["source","java",subs="attributes,callouts,macros"]
  29. --------------------------------------------------
  30. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[put-settings-settings-builder]
  31. --------------------------------------------------
  32. <1> Settings provided as `Settings.Builder`
  33. ["source","java",subs="attributes,callouts,macros"]
  34. --------------------------------------------------
  35. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[put-settings-settings-source]
  36. --------------------------------------------------
  37. <1> Settings provided as `String`
  38. ["source","java",subs="attributes,callouts,macros"]
  39. --------------------------------------------------
  40. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[put-settings-settings-map]
  41. --------------------------------------------------
  42. <1> Settings provided as a `Map`
  43. ==== Optional Arguments
  44. The following arguments can optionally be provided:
  45. ["source","java",subs="attributes,callouts,macros"]
  46. --------------------------------------------------
  47. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[put-settings-request-preserveExisting]
  48. --------------------------------------------------
  49. <1> Whether to update existing settings. If set to `true` existing settings
  50. on an index remain unchanged, the default is `false`
  51. ["source","java",subs="attributes,callouts,macros"]
  52. --------------------------------------------------
  53. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[put-settings-request-timeout]
  54. --------------------------------------------------
  55. <1> Timeout to wait for the all the nodes to acknowledge the new setting
  56. as a `TimeValue`
  57. <2> Timeout to wait for the all the nodes to acknowledge the new setting
  58. as a `String`
  59. ["source","java",subs="attributes,callouts,macros"]
  60. --------------------------------------------------
  61. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[put-settings-request-masterTimeout]
  62. --------------------------------------------------
  63. <1> Timeout to connect to the master node as a `TimeValue`
  64. <2> Timeout to connect to the master node as a `String`
  65. ["source","java",subs="attributes,callouts,macros"]
  66. --------------------------------------------------
  67. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[put-settings-request-indicesOptions]
  68. --------------------------------------------------
  69. <1> Setting `IndicesOptions` controls how unavailable indices are resolved and
  70. how wildcard expressions are expanded
  71. [[java-rest-high-indices-put-settings-sync]]
  72. ==== Synchronous Execution
  73. ["source","java",subs="attributes,callouts,macros"]
  74. --------------------------------------------------
  75. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[put-settings-execute]
  76. --------------------------------------------------
  77. [[java-rest-high-indices-put-settings-async]]
  78. ==== Asynchronous Execution
  79. The asynchronous execution of an indices update settings requires both the
  80. `UpdateSettingsRequest` instance and an `ActionListener` instance to be
  81. passed to the asynchronous method:
  82. ["source","java",subs="attributes,callouts,macros"]
  83. --------------------------------------------------
  84. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[put-settings-execute-async]
  85. --------------------------------------------------
  86. <1> The `UpdateSettingsRequest` to execute and the `ActionListener`
  87. to use when the execution completes
  88. The asynchronous method does not block and returns immediately. Once it is
  89. completed the `ActionListener` is called back using the `onResponse` method
  90. if the execution successfully completed or using the `onFailure` method if
  91. it failed.
  92. A typical listener for `UpdateSettingsResponse` looks like:
  93. ["source","java",subs="attributes,callouts,macros"]
  94. --------------------------------------------------
  95. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[put-settings-execute-listener]
  96. --------------------------------------------------
  97. <1> Called when the execution is successfully completed. The response is
  98. provided as an argument
  99. <2> Called in case of a failure. The raised exception is provided as an argument
  100. [[java-rest-high-indices-put-settings-response]]
  101. ==== Update Indices Settings Response
  102. The returned `UpdateSettingsResponse` allows to retrieve information about the
  103. executed operation as follows:
  104. ["source","java",subs="attributes,callouts,macros"]
  105. --------------------------------------------------
  106. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[put-settings-response]
  107. --------------------------------------------------
  108. <1> Indicates whether all of the nodes have acknowledged the request