get_index.asciidoc 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. [[java-rest-high-get-index]]
  2. === Get Index API
  3. [[java-rest-high-get-index-request]]
  4. ==== Get Index Request
  5. A `GetIndexRequest` requires one or more `index` arguments:
  6. ["source","java",subs="attributes,callouts,macros"]
  7. --------------------------------------------------
  8. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-index-request]
  9. --------------------------------------------------
  10. <1> The index whose information we want to 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-index-request-includeDefaults]
  16. --------------------------------------------------
  17. <1> If true, defaults will be returned for settings not explicitly set on the index
  18. ["source","java",subs="attributes,callouts,macros"]
  19. --------------------------------------------------
  20. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-index-request-indicesOptions]
  21. --------------------------------------------------
  22. <1> Setting `IndicesOptions` controls how unavailable indices are resolved and
  23. how wildcard expressions are expanded
  24. [[java-rest-high-get-index-sync]]
  25. ==== Synchronous Execution
  26. ["source","java",subs="attributes,callouts,macros"]
  27. --------------------------------------------------
  28. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-index-execute]
  29. --------------------------------------------------
  30. [[java-rest-high-get-index-async]]
  31. ==== Asynchronous Execution
  32. The asynchronous execution of a Get Index request requires both the `GetIndexRequest`
  33. instance and an `ActionListener` instance to be passed to the asynchronous
  34. method:
  35. ["source","java",subs="attributes,callouts,macros"]
  36. --------------------------------------------------
  37. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-index-execute-async]
  38. --------------------------------------------------
  39. <1> The `GetIndexRequest` to execute and the `ActionListener` to use when
  40. the execution completes
  41. The asynchronous method does not block and returns immediately. Once it is
  42. completed the `ActionListener` is called back using the `onResponse` method
  43. if the execution successfully completed or using the `onFailure` method if
  44. it failed.
  45. A typical listener for `GetIndexResponse` looks like:
  46. ["source","java",subs="attributes,callouts,macros"]
  47. --------------------------------------------------
  48. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-index-execute-listener]
  49. --------------------------------------------------
  50. <1> Called when the execution is successfully completed. The response is
  51. provided as an argument.
  52. <2> Called in case of failure. The raised exception is provided as an argument.
  53. [[java-rest-high-get-index-response]]
  54. ==== Get Index Response
  55. The returned `GetIndexResponse` allows to retrieve information about the
  56. executed operation as follows:
  57. ["source","java",subs="attributes,callouts,macros"]
  58. --------------------------------------------------
  59. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-index-response]
  60. --------------------------------------------------
  61. <1> Retrieve a Map of different types to `MappingMetadata` for `index`.
  62. <2> Retrieve a Map for the properties for document type `doc`.
  63. <3> Get the list of aliases for `index`.
  64. <4> Get the value for the setting string `index.number_of_shards` for `index`. If the setting was not explicitly
  65. specified but was part of the default settings (and includeDefault was `true`) then the default setting would be
  66. retrieved.
  67. <5> Retrieve all settings for `index`.
  68. <6> The `Settings` objects gives more flexibility. Here it is used to extract the setting `index.number_of_shards` as an
  69. integer.
  70. <7> Get the default setting `index.refresh_interval` (if `includeDefault` was set to `true`). If `includeDefault` was set
  71. to `false`, `getIndexResponse.defaultSettings()` will return an empty map.