indices_exists.asciidoc 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. [[java-rest-high-indices-exists]]
  2. === Indices Exists API
  3. [[java-rest-high-indices-exists-request]]
  4. ==== Indices Exists Request
  5. The high-level REST client uses a `GetIndexRequest` for Indices Exists API. The index name (or indices' names) are required.
  6. ["source","java",subs="attributes,callouts,macros"]
  7. --------------------------------------------------
  8. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[indices-exists-request]
  9. --------------------------------------------------
  10. <1> Index
  11. [[java-rest-high-indices-exists-optional-args]]
  12. ==== Optional arguments
  13. Indices Exists API also accepts following optional arguments, through a `GetIndexRequest`:
  14. ["source","java",subs="attributes,callouts,macros"]
  15. --------------------------------------------------
  16. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[indices-exists-request-optionals]
  17. --------------------------------------------------
  18. <1> Whether to return local information or retrieve the state from master node
  19. <2> Return result in a format suitable for humans
  20. <3> Whether to return all default setting for each of the indices
  21. <4> Controls how unavailable indices are resolved and how wildcard expressions are expanded
  22. [[java-rest-high-indices-sync]]
  23. ==== Synchronous Execution
  24. ["source","java",subs="attributes,callouts,macros"]
  25. --------------------------------------------------
  26. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[indices-exists-response]
  27. --------------------------------------------------
  28. [[java-rest-high-indices-async]]
  29. ==== Asynchronous Execution
  30. The asynchronous execution of an indices exists request requires both the
  31. `GetIndexRequest` instance and an `ActionListener` instance to be passed
  32. to the asynchronous method:
  33. ["source","java",subs="attributes,callouts,macros"]
  34. --------------------------------------------------
  35. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[indices-exists-async]
  36. --------------------------------------------------
  37. <1> The `GetIndexRequest` to execute and the `ActionListener` to use when
  38. the execution completes
  39. The asynchronous method does not block and returns immediately. Once it is
  40. completed the `ActionListener` is called back using the `onResponse` method
  41. if the execution successfully completed or using the `onFailure` method if
  42. it failed.
  43. A typical listener for the Indices Exists looks like:
  44. ["source","java",subs="attributes,callouts,macros"]
  45. --------------------------------------------------
  46. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[indices-exists-execute-listener]
  47. --------------------------------------------------
  48. <1> Called when the execution is successfully completed. The response is
  49. provided as an argument
  50. <2> Called in case of failure. The raised exception is provided as an argument
  51. [[java-rest-high-indices-exists-response]]
  52. ==== Response
  53. The response is a `boolean` value, indicating whether the index (or indices) exist:
  54. ["source","java",subs="attributes,callouts,macros"]
  55. --------------------------------------------------
  56. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[indices-exists-response]
  57. --------------------------------------------------