get_mappings.asciidoc 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. [[java-rest-high-get-mappings]]
  2. === Get Mappings API
  3. [[java-rest-high-get-mappings-request]]
  4. ==== Get Mappings Request
  5. A `GetMappingsRequest` can have an optional list of indices and optional list of types:
  6. ["source","java",subs="attributes,callouts,macros"]
  7. --------------------------------------------------
  8. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-mapping-request]
  9. --------------------------------------------------
  10. <1> An empty request that will return all indices and types
  11. <2> Setting the indices to fetch mapping for
  12. <3> The types to be returned
  13. ==== Optional arguments
  14. The following arguments can also optionally be provided:
  15. ["source","java",subs="attributes,callouts,macros"]
  16. --------------------------------------------------
  17. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-mapping-request-masterTimeout]
  18. --------------------------------------------------
  19. <1> Timeout to connect to the master node as a `TimeValue`
  20. <2> Timeout to connect to the master node as a `String`
  21. ["source","java",subs="attributes,callouts,macros"]
  22. --------------------------------------------------
  23. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-mapping-request-indicesOptions]
  24. --------------------------------------------------
  25. <1> Options for expanding indices names
  26. [[java-rest-high-get-mappings-sync]]
  27. ==== Synchronous Execution
  28. ["source","java",subs="attributes,callouts,macros"]
  29. --------------------------------------------------
  30. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-mapping-execute]
  31. --------------------------------------------------
  32. [[java-rest-high-get-mapping-async]]
  33. ==== Asynchronous Execution
  34. The asynchronous execution of a get mappings request requires both the
  35. `GetMappingsRequest` instance and an `ActionListener` instance to be passed to
  36. the asynchronous method:
  37. ["source","java",subs="attributes,callouts,macros"]
  38. --------------------------------------------------
  39. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-mapping-execute-async]
  40. --------------------------------------------------
  41. <1> The `GetMappingsRequest` to execute and the `ActionListener` to use when the execution completes
  42. The asynchronous method does not block and returns immediately. Once it is
  43. completed the `ActionListener` is called back using the `onResponse` method if
  44. the execution successfully completed or using the `onFailure` method if it
  45. failed.
  46. A typical listener for `GetMappingsResponse` looks like:
  47. ["source","java",subs="attributes,callouts,macros"]
  48. --------------------------------------------------
  49. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-mapping-execute-listener]
  50. --------------------------------------------------
  51. <1> Called when the execution is successfully completed. The response is provided as an argument
  52. <2> Called in case of failure. The raised exception is provided as an argument
  53. [[java-rest-high-get-mapping-response]]
  54. ==== Get Mappings Response
  55. The returned `GetMappingsResponse` allows to retrieve information about the
  56. executed operation as follows:
  57. ["source","java",subs="attributes,callouts,macros"]
  58. --------------------------------------------------
  59. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-mapping-response]
  60. --------------------------------------------------
  61. <1> Returning all indices' mappings
  62. <2> Retrieving the mappings for a particular index and type
  63. <3> Getting the mappings as a Java Map