refresh.asciidoc 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. [[java-rest-high-refresh]]
  2. === Refresh API
  3. [[java-rest-high-refresh-request]]
  4. ==== Refresh Request
  5. A `RefreshRequest` can be applied to one or more indices, or even on `_all` the indices:
  6. ["source","java",subs="attributes,callouts,macros"]
  7. --------------------------------------------------
  8. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[refresh-request]
  9. --------------------------------------------------
  10. <1> Refresh one index
  11. <2> Refresh multiple indices
  12. <3> Refresh all the indices
  13. ==== Optional arguments
  14. ["source","java",subs="attributes,callouts,macros"]
  15. --------------------------------------------------
  16. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[refresh-request-indicesOptions]
  17. --------------------------------------------------
  18. <1> Setting `IndicesOptions` controls how unavailable indices are resolved and
  19. how wildcard expressions are expanded
  20. [[java-rest-high-refresh-sync]]
  21. ==== Synchronous Execution
  22. ["source","java",subs="attributes,callouts,macros"]
  23. --------------------------------------------------
  24. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[refresh-execute]
  25. --------------------------------------------------
  26. [[java-rest-high-refresh-async]]
  27. ==== Asynchronous Execution
  28. The asynchronous execution of a refresh request requires both the `RefreshRequest`
  29. instance and an `ActionListener` instance to be passed to the asynchronous
  30. method:
  31. ["source","java",subs="attributes,callouts,macros"]
  32. --------------------------------------------------
  33. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[refresh-execute-async]
  34. --------------------------------------------------
  35. <1> The `RefreshRequest` to execute and the `ActionListener` to use when
  36. the execution completes
  37. The asynchronous method does not block and returns immediately. Once it is
  38. completed the `ActionListener` is called back using the `onResponse` method
  39. if the execution successfully completed or using the `onFailure` method if
  40. it failed.
  41. A typical listener for `RefreshResponse` looks like:
  42. ["source","java",subs="attributes,callouts,macros"]
  43. --------------------------------------------------
  44. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[refresh-execute-listener]
  45. --------------------------------------------------
  46. <1> Called when the execution is successfully completed. The response is
  47. provided as an argument
  48. <2> Called in case of failure. The raised exception is provided as an argument
  49. [[java-rest-high-refresh-response]]
  50. ==== Refresh Response
  51. The returned `RefreshResponse` allows to retrieve information about the
  52. executed operation as follows:
  53. ["source","java",subs="attributes,callouts,macros"]
  54. --------------------------------------------------
  55. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[refresh-response]
  56. --------------------------------------------------
  57. <1> Total number of shards hit by the refresh request
  58. <2> Number of shards where the refresh has succeeded
  59. <3> Number of shards where the refresh has failed
  60. <4> A list of failures if the operation failed on one or more shards
  61. By default, if the indices were not found, an `ElasticsearchException` will be thrown:
  62. ["source","java",subs="attributes,callouts,macros"]
  63. --------------------------------------------------
  64. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[refresh-notfound]
  65. --------------------------------------------------
  66. <1> Do something if the indices to be refreshed were not found