get-source.asciidoc 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. --
  2. :api: get-source
  3. :request: GetSourceRequest
  4. :response: GetSourceResponse
  5. --
  6. [id="{upid}-{api}"]
  7. === Get Source API
  8. This API helps to get only the `_source` field of a document.
  9. [id="{upid}-{api}-request"]
  10. ==== Get Source Request
  11. A +{request}+ requires the following arguments:
  12. ["source","java",subs="attributes,callouts,macros"]
  13. --------------------------------------------------
  14. include-tagged::{doc-tests-file}[{api}-request]
  15. --------------------------------------------------
  16. <1> Index
  17. <2> Document id
  18. [id="{upid}-{api}-request-optional"]
  19. ==== Optional arguments
  20. The following arguments can optionally be provided:
  21. ["source","java",subs="attributes,callouts,macros"]
  22. --------------------------------------------------
  23. include-tagged::{doc-tests-file}[{api}-request-optional]
  24. --------------------------------------------------
  25. <1> `FetchSourceContext` 's first argument `fetchSource` must be `true`, otherwise
  26. `ElasticsearchException` get thrown
  27. <2> Arguments of the context `excludes` and `includes` are optional
  28. (see examples in Get API documentation)
  29. ["source","java",subs="attributes,callouts,macros"]
  30. --------------------------------------------------
  31. include-tagged::{doc-tests-file}[{api}-request-routing]
  32. --------------------------------------------------
  33. <1> Routing value
  34. ["source","java",subs="attributes,callouts,macros"]
  35. --------------------------------------------------
  36. include-tagged::{doc-tests-file}[{api}-request-preference]
  37. --------------------------------------------------
  38. <1> Preference value
  39. ["source","java",subs="attributes,callouts,macros"]
  40. --------------------------------------------------
  41. include-tagged::{doc-tests-file}[{api}-request-realtime]
  42. --------------------------------------------------
  43. <1> Set realtime flag to `false` (`true` by default)
  44. ["source","java",subs="attributes,callouts,macros"]
  45. --------------------------------------------------
  46. include-tagged::{doc-tests-file}[{api}-request-refresh]
  47. --------------------------------------------------
  48. <1> Perform a refresh before retrieving the document (`false` by default)
  49. include::../execution.asciidoc[]
  50. [id="{upid}-{api}-response"]
  51. ==== Get Source Response
  52. The returned +{response}+ contains the field `source` that represents the
  53. source of a document as a map.
  54. ["source","java",subs="attributes,callouts,macros"]
  55. --------------------------------------------------
  56. include-tagged::{doc-tests-file}[{api}-response]
  57. --------------------------------------------------