get_field_mappings.asciidoc 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. [[java-rest-high-get-field-mappings]]
  2. === Get Field Mappings API
  3. [[java-rest-high-get-field-mappings-request]]
  4. ==== Get Field Mappings Request
  5. A `GetFieldMappingsRequest` can have an optional list of indices, optional list of types and the list of fields:
  6. ["source","java",subs="attributes,callouts,macros"]
  7. --------------------------------------------------
  8. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-field-mapping-request]
  9. --------------------------------------------------
  10. <1> An empty request
  11. <2> Setting the indices to fetch mapping for
  12. <3> The types to be returned
  13. <4> The fields to be returned
  14. ==== Optional arguments
  15. The following arguments can also optionally be provided:
  16. ["source","java",subs="attributes,callouts,macros"]
  17. --------------------------------------------------
  18. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-field-mapping-request-indicesOptions]
  19. --------------------------------------------------
  20. <1> Setting `IndicesOptions` controls how unavailable indices are resolved and
  21. how wildcard expressions are expanded
  22. ["source","java",subs="attributes,callouts,macros"]
  23. --------------------------------------------------
  24. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-field-mapping-request-local]
  25. --------------------------------------------------
  26. <1> The `local` flag (defaults to `false`) controls whether the aliases need
  27. to be looked up in the local cluster state or in the cluster state held by
  28. the elected master node
  29. [[java-rest-high-get-field-mappings-sync]]
  30. ==== Synchronous Execution
  31. ["source","java",subs="attributes,callouts,macros"]
  32. --------------------------------------------------
  33. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-field-mapping-execute]
  34. --------------------------------------------------
  35. [[java-rest-high-get-field-mapping-async]]
  36. ==== Asynchronous Execution
  37. The asynchronous execution of a get mappings request requires both the
  38. `GetFieldMappingsRequest` instance and an `ActionListener` instance to be passed to
  39. the asynchronous method:
  40. ["source","java",subs="attributes,callouts,macros"]
  41. --------------------------------------------------
  42. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-field-mapping-execute-async]
  43. --------------------------------------------------
  44. <1> The `GetFieldMappingsRequest` to execute and the `ActionListener` to use when the execution completes
  45. The asynchronous method does not block and returns immediately. Once it is
  46. completed the `ActionListener` is called back using the `onResponse` method if
  47. the execution successfully completed or using the `onFailure` method if it
  48. failed.
  49. A typical listener for `GetMappingsResponse` looks like:
  50. ["source","java",subs="attributes,callouts,macros"]
  51. --------------------------------------------------
  52. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-field-mapping-execute-listener]
  53. --------------------------------------------------
  54. <1> Called when the execution is successfully completed. The response is provided as an argument
  55. <2> Called in case of failure. The raised exception is provided as an argument
  56. [[java-rest-high-get-field-mapping-response]]
  57. ==== Get Field Mappings Response
  58. The returned `GetFieldMappingsResponse` allows to retrieve information about the
  59. executed operation as follows:
  60. ["source","java",subs="attributes,callouts,macros"]
  61. --------------------------------------------------
  62. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-field-mapping-response]
  63. --------------------------------------------------
  64. <1> Returning all requested indices fields' mappings
  65. <2> Retrieving the mappings for a particular index and type
  66. <3> Getting the mappings metadata for the `message` field
  67. <4> Getting the full name of the field
  68. <5> Getting the mapping source of the field