flush_synced.asciidoc 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. [[java-rest-high-flush-synced]]
  2. === Flush Synced API
  3. [[java-rest-high-flush-synced-request]]
  4. ==== Flush Synced Request
  5. A `SyncedFlushRequest` 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[flush-synced-request]
  9. --------------------------------------------------
  10. <1> Flush synced one index
  11. <2> Flush synced multiple indices
  12. <3> Flush synced all the indices
  13. ==== Optional arguments
  14. ["source","java",subs="attributes,callouts,macros"]
  15. --------------------------------------------------
  16. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[flush-synced-request-indicesOptions]
  17. --------------------------------------------------
  18. <1> Setting `IndicesOptions` controls how unavailable indices are resolved and
  19. how wildcard expressions are expanded
  20. [[java-rest-high-flush-synced-sync]]
  21. ==== Synchronous Execution
  22. ["source","java",subs="attributes,callouts,macros"]
  23. --------------------------------------------------
  24. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[flush-synced-execute]
  25. --------------------------------------------------
  26. [[java-rest-high-flush-synced-async]]
  27. ==== Asynchronous Execution
  28. The asynchronous execution of a flush request requires both the `SyncedFlushRequest`
  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[flush-synced-execute-async]
  34. --------------------------------------------------
  35. <1> The `SyncedFlushRequest` 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 `SyncedFlushResponse` looks like:
  42. ["source","java",subs="attributes,callouts,macros"]
  43. --------------------------------------------------
  44. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[flush-synced-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-flush-synced-response]]
  50. ==== Flush Synced Response
  51. The returned `SyncedFlushResponse` 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[flush-synced-response]
  56. --------------------------------------------------
  57. <1> Total number of shards hit by the flush request
  58. <2> Number of shards where the flush has succeeded
  59. <3> Number of shards where the flush has failed
  60. <4> Name of the index whose results we are about to calculate.
  61. <5> Total number of shards for index mentioned in 4.
  62. <6> Successful shards for index mentioned in 4.
  63. <7> Failed shards for index mentioned in 4.
  64. <8> One of the failed shard ids of the failed index mentioned in 4.
  65. <9> Reason for failure of copies of the shard mentioned in 8.
  66. <10> JSON represented by a Map<String, Object>. Contains shard related information like id, state, version etc.
  67. for the failed shard copies. If the entire shard failed then this returns an empty map.
  68. By default, if the indices were not found, an `ElasticsearchException` will be thrown:
  69. ["source","java",subs="attributes,callouts,macros"]
  70. --------------------------------------------------
  71. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[flush-synced-notfound]
  72. --------------------------------------------------
  73. <1> Do something if the indices to be flushed were not found