12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- [[java-rest-high-get-index]]
- === Get Index API
- [[java-rest-high-get-index-request]]
- ==== Get Index Request
- A `GetIndexRequest` requires one or more `index` arguments:
- ["source","java",subs="attributes,callouts,macros"]
- --------------------------------------------------
- include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-index-request]
- --------------------------------------------------
- <1> The index whose information we want to retrieve
- ==== Optional arguments
- The following arguments can optionally be provided:
- ["source","java",subs="attributes,callouts,macros"]
- --------------------------------------------------
- include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-index-request-includeDefaults]
- --------------------------------------------------
- <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-index-request-indicesOptions]
- --------------------------------------------------
- <1> Setting `IndicesOptions` controls how unavailable indices are resolved and
- how wildcard expressions are expanded
- [[java-rest-high-get-index-sync]]
- ==== Synchronous Execution
- ["source","java",subs="attributes,callouts,macros"]
- --------------------------------------------------
- include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-index-execute]
- --------------------------------------------------
- [[java-rest-high-get-index-async]]
- ==== Asynchronous Execution
- The asynchronous execution of a Get Index request requires both the `GetIndexRequest`
- 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-index-execute-async]
- --------------------------------------------------
- <1> The `GetIndexRequest` 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 `GetIndexResponse` looks like:
- ["source","java",subs="attributes,callouts,macros"]
- --------------------------------------------------
- include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-index-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-index-response]]
- ==== Get Index Response
- The returned `GetIndexResponse` allows to retrieve information about the
- executed operation as follows:
- ["source","java",subs="attributes,callouts,macros"]
- --------------------------------------------------
- include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-index-response]
- --------------------------------------------------
- <1> Retrieve a Map of different types to `MappingMetadata` for `index`.
- <2> Retrieve a Map for the properties for document type `doc`.
- <3> Get the list of aliases for `index`.
- <4> Get the value for the setting string `index.number_of_shards` for `index`. If the setting was not explicitly
- specified but was part of the default settings (and includeDefault was `true`) then the default setting would be
- retrieved.
- <5> Retrieve all settings for `index`.
- <6> The `Settings` objects gives more flexibility. Here it is used to extract the setting `index.number_of_shards` as an
- integer.
- <7> Get the default setting `index.refresh_interval` (if `includeDefault` was set to `true`). If `includeDefault` was set
- to `false`, `getIndexResponse.defaultSettings()` will return an empty map.
|