get.asciidoc 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. --
  2. :api: asyncsearch-get
  3. :request: GetAsyncSearchRequest
  4. :response: AsyncSearchResponse
  5. --
  6. [role="xpack"]
  7. [id="{upid}-{api}"]
  8. === Get Async Search API
  9. [id="{upid}-{api}-request"]
  10. ==== Request
  11. A +{request}+ allows to get a running asynchronous search task by
  12. its id. Required arguments are the `id` of a running async search:
  13. ["source","java",subs="attributes,callouts,macros"]
  14. --------------------------------------------------
  15. include-tagged::{doc-tests-file}[{api}-request]
  16. --------------------------------------------------
  17. ==== Optional arguments
  18. The following arguments can optionally be provided:
  19. ["source","java",subs="attributes,callouts,macros"]
  20. --------------------------------------------------
  21. include-tagged::{doc-tests-file}[{api}-request-arguments]
  22. --------------------------------------------------
  23. <1> The minimum time that the request should wait before
  24. returning a partial result (defaults to no wait).
  25. <2> The expiration time of the request (defaults to none).
  26. [id="{upid}-{api}-sync"]
  27. ==== Synchronous Execution
  28. ["source","java",subs="attributes,callouts,macros"]
  29. --------------------------------------------------
  30. include-tagged::{doc-tests-file}[{api}-execute]
  31. --------------------------------------------------
  32. <1> Execute the request and get back the response as an +{response}+ object.
  33. [id="{upid}-{api}-async"]
  34. ==== Asynchronous Execution
  35. The asynchronous execution of a +{request}+ allows to use an
  36. `ActionListener` to be called back when the submit request returns:
  37. ["source","java",subs="attributes,callouts,macros"]
  38. --------------------------------------------------
  39. include-tagged::{doc-tests-file}[{api}-execute-async]
  40. --------------------------------------------------
  41. <1> The +{request}+ to execute and the `ActionListener` to use when
  42. the execution completes
  43. The asynchronous method does not block and returns immediately. Once it is
  44. completed the `ActionListener` is called back using the `onResponse` method
  45. if the execution successfully completed or using the `onFailure` method if
  46. it failed.
  47. A typical listener for +{response}+ looks like:
  48. ["source","java",subs="attributes,callouts,macros"]
  49. --------------------------------------------------
  50. include-tagged::{doc-tests-file}[{api}-listener]
  51. --------------------------------------------------
  52. <1> Called when the execution is successfully completed. The response is
  53. provided as an argument
  54. <2> Called in case of failure. The raised exception is provided as an argument
  55. [id="{upid}-{api}-response"]
  56. ==== Response
  57. The returned +{response}+ allows to retrieve information about the executed
  58. operation as follows:
  59. ["source","java",subs="attributes,callouts,macros"]
  60. --------------------------------------------------
  61. include-tagged::{doc-tests-file}[{api}-response]
  62. --------------------------------------------------
  63. <1> The `SearchResponse`, or `null` if not available yet
  64. <2> The id of the async search request, `null` if the response isn't stored
  65. <3> `true` when the response contains partial results
  66. <4> `true` when the search is still running
  67. <5> The time the response was created (millis since epoch)
  68. <6> The time the response expires (millis since epoch)
  69. <7> Get failure reasons or `null` for no failures