indices_exists.asciidoc 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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> Return settings in flat format
  22. <5> Controls how unavailable indices are resolved and how wildcard expressions are expanded
  23. [[java-rest-high-indices-sync]]
  24. ==== Synchronous Execution
  25. ["source","java",subs="attributes,callouts,macros"]
  26. --------------------------------------------------
  27. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[indices-exists-response]
  28. --------------------------------------------------
  29. [[java-rest-high-indices-async]]
  30. ==== Asynchronous Execution
  31. The asynchronous execution of an indices exists request requires both the
  32. `GetIndexRequest` instance and an `ActionListener` instance to be passed
  33. to the asynchronous method:
  34. ["source","java",subs="attributes,callouts,macros"]
  35. --------------------------------------------------
  36. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[indices-exists-async]
  37. --------------------------------------------------
  38. <1> The `GetIndexRequest` to execute and the `ActionListener` to use when
  39. the execution completes
  40. The asynchronous method does not block and returns immediately. Once it is
  41. completed the `ActionListener` is called back using the `onResponse` method
  42. if the execution successfully completed or using the `onFailure` method if
  43. it failed.
  44. A typical listener for the Indices Exists looks like:
  45. ["source","java",subs="attributes,callouts,macros"]
  46. --------------------------------------------------
  47. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[indices-exists-execute-listener]
  48. --------------------------------------------------
  49. <1> Called when the execution is successfully completed. The response is
  50. provided as an argument
  51. <2> Called in case of failure. The raised exception is provided as an argument
  52. [[java-rest-high-indices-exists-response]]
  53. ==== Response
  54. The response is a `boolean` value, indicating whether the index (or indices) exist:
  55. ["source","java",subs="attributes,callouts,macros"]
  56. --------------------------------------------------
  57. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[indices-exists-response]
  58. --------------------------------------------------