get_settings.asciidoc 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. [[java-rest-high-get-settings]]
  2. === Get Settings API
  3. [[java-rest-high-get-settings-request]]
  4. ==== Get Settings Request
  5. A `GetSettingsRequest` requires one or more `index` arguments:
  6. ["source","java",subs="attributes,callouts,macros"]
  7. --------------------------------------------------
  8. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-settings-request]
  9. --------------------------------------------------
  10. <1> The index whose settings we should retrieve
  11. ==== Optional arguments
  12. The following arguments can optionally be provided:
  13. ["source","java",subs="attributes,callouts,macros"]
  14. --------------------------------------------------
  15. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-settings-request-names]
  16. --------------------------------------------------
  17. <1> One or more settings that be the only settings retrieved. If unset, all settings will be retrieved
  18. ["source","java",subs="attributes,callouts,macros"]
  19. --------------------------------------------------
  20. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-settings-request-include-defaults]
  21. --------------------------------------------------
  22. <1> If true, defaults will be returned for settings not explicitly set on the index
  23. ["source","java",subs="attributes,callouts,macros"]
  24. --------------------------------------------------
  25. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-settings-request-indicesOptions]
  26. --------------------------------------------------
  27. <1> Setting `IndicesOptions` controls how unavailable indices are resolved and
  28. how wildcard expressions are expanded
  29. [[java-rest-high-get-settings-sync]]
  30. ==== Synchronous Execution
  31. ["source","java",subs="attributes,callouts,macros"]
  32. --------------------------------------------------
  33. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-settings-execute]
  34. --------------------------------------------------
  35. [[java-rest-high-get-settings-async]]
  36. ==== Asynchronous Execution
  37. The asynchronous execution of a Get Settings request requires both the `GetSettingsRequest`
  38. instance and an `ActionListener` instance to be passed to the asynchronous
  39. method:
  40. ["source","java",subs="attributes,callouts,macros"]
  41. --------------------------------------------------
  42. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-settings-execute-async]
  43. --------------------------------------------------
  44. <1> The `GetSettingsRequest` to execute and the `ActionListener` to use when
  45. the execution completes
  46. The asynchronous method does not block and returns immediately. Once it is
  47. completed the `ActionListener` is called back using the `onResponse` method
  48. if the execution successfully completed or using the `onFailure` method if
  49. it failed.
  50. A typical listener for `GetSettingsResponse` looks like:
  51. ["source","java",subs="attributes,callouts,macros"]
  52. --------------------------------------------------
  53. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-settings-execute-listener]
  54. --------------------------------------------------
  55. <1> Called when the execution is successfully completed. The response is
  56. provided as an argument
  57. <2> Called in case of failure. The raised exception is provided as an argument
  58. [[java-rest-high-get-settings-response]]
  59. ==== Get Settings Response
  60. The returned `GetSettingsResponse` allows to retrieve information about the
  61. executed operation as follows:
  62. ["source","java",subs="attributes,callouts,macros"]
  63. --------------------------------------------------
  64. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-settings-response]
  65. --------------------------------------------------
  66. <1> We can retrieve the setting value for a particular index directly from the response as a string
  67. <2> We can also retrieve the Settings object for a particular index for further examination
  68. <3> The returned Settings object provides convenience methods for non String types
  69. If the `includeDefaults` flag was set to true in the `GetSettingsRequest`, the
  70. behavior of `GetSettingsResponse` will differ somewhat.
  71. ["source","java",subs="attributes,callouts,macros"]
  72. --------------------------------------------------
  73. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-settings-defaults-response]
  74. --------------------------------------------------
  75. <1> Individual default setting values may be retrieved directly from the `GetSettingsResponse`
  76. <2> We may retrieve a Settings object for an index that contains those settings with default values