mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-06 13:08:29 +00:00
0a93956194
This PR adds support for the Get Settings API to the java high-level rest client. Furthermore, logic related to the retrieval of default settings has been moved from the rest layer into the transport layer and now default settings may be retrieved consistency via both the rest API and the transport API.
97 lines
4.4 KiB
Plaintext
97 lines
4.4 KiB
Plaintext
[[java-rest-high-get-settings]]
|
|
=== Get Settings API
|
|
|
|
[[java-rest-high-get-settings-request]]
|
|
==== Get Settings Request
|
|
|
|
A `GetSettingsRequest` requires one or more `index` arguments:
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
--------------------------------------------------
|
|
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-settings-request]
|
|
--------------------------------------------------
|
|
<1> The index whose settings we should retrieve
|
|
|
|
==== Optional arguments
|
|
The following arguments can optionally be provided:
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
--------------------------------------------------
|
|
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-settings-request-names]
|
|
--------------------------------------------------
|
|
<1> One or more settings that be the only settings retrieved. If unset, all settings will be retrieved
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
--------------------------------------------------
|
|
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-settings-request-include-defaults]
|
|
--------------------------------------------------
|
|
<1> If true, defaults will be returned for settings not explicitly set on the index
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
--------------------------------------------------
|
|
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-settings-request-indicesOptions]
|
|
--------------------------------------------------
|
|
<1> Setting `IndicesOptions` controls how unavailable indices are resolved and
|
|
how wildcard expressions are expanded
|
|
|
|
[[java-rest-high-get-settings-sync]]
|
|
==== Synchronous Execution
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
--------------------------------------------------
|
|
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-settings-execute]
|
|
--------------------------------------------------
|
|
|
|
[[java-rest-high-get-settings-async]]
|
|
==== Asynchronous Execution
|
|
|
|
The asynchronous execution of a Get Settings request requires both the `GetSettingsRequest`
|
|
instance and an `ActionListener` instance to be passed to the asynchronous
|
|
method:
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
--------------------------------------------------
|
|
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-settings-execute-async]
|
|
--------------------------------------------------
|
|
<1> The `GetSettingsRequest` to execute and the `ActionListener` to use when
|
|
the execution completes
|
|
|
|
The asynchronous method does not block and returns immediately. Once it is
|
|
completed the `ActionListener` is called back using the `onResponse` method
|
|
if the execution successfully completed or using the `onFailure` method if
|
|
it failed.
|
|
|
|
A typical listener for `GetSettingsResponse` looks like:
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
--------------------------------------------------
|
|
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-settings-execute-listener]
|
|
--------------------------------------------------
|
|
<1> Called when the execution is successfully completed. The response is
|
|
provided as an argument
|
|
<2> Called in case of failure. The raised exception is provided as an argument
|
|
|
|
[[java-rest-high-get-settings-response]]
|
|
==== Get Settings Response
|
|
|
|
The returned `GetSettingsResponse` allows to retrieve information about the
|
|
executed operation as follows:
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
--------------------------------------------------
|
|
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-settings-response]
|
|
--------------------------------------------------
|
|
<1> We can retrieve the setting value for a particular index directly from the response as a string
|
|
<2> We can also retrieve the Settings object for a particular index for further examination
|
|
<3> The returned Settings object provides convenience methods for non String types
|
|
|
|
If the `includeDefaults` flag was set to true in the `GetSettingsRequest`, the
|
|
behavior of `GetSettingsResponse` will differ somewhat.
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
--------------------------------------------------
|
|
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-settings-defaults-response]
|
|
--------------------------------------------------
|
|
<1> Individual default setting values may be retrieved directly from the `GetSettingsResponse`
|
|
<2> We may retrieve a Settings object for an index that contains those settings with default values
|