mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-04-24 23:27:25 -04:00
Add get field mappings to High Level REST API Client (#31423)
Add get field mappings to High Level REST API Client Relates to #27205
This commit is contained in:
parent
b6cc6fc2bc
commit
b7ef75fed6
9 changed files with 562 additions and 8 deletions
|
@ -0,0 +1,86 @@
|
|||
[[java-rest-high-get-field-mappings]]
|
||||
=== Get Field Mappings API
|
||||
|
||||
[[java-rest-high-get-field-mappings-request]]
|
||||
==== Get Field Mappings Request
|
||||
|
||||
A `GetFieldMappingsRequest` can have an optional list of indices, optional list of types and the list of fields:
|
||||
|
||||
["source","java",subs="attributes,callouts,macros"]
|
||||
--------------------------------------------------
|
||||
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-field-mapping-request]
|
||||
--------------------------------------------------
|
||||
<1> An empty request
|
||||
<2> Setting the indices to fetch mapping for
|
||||
<3> The types to be returned
|
||||
<4> The fields to be returned
|
||||
|
||||
==== Optional arguments
|
||||
The following arguments can also optionally be provided:
|
||||
|
||||
["source","java",subs="attributes,callouts,macros"]
|
||||
--------------------------------------------------
|
||||
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-field-mapping-request-indicesOptions]
|
||||
--------------------------------------------------
|
||||
<1> Setting `IndicesOptions` controls how unavailable indices are resolved and
|
||||
how wildcard expressions are expanded
|
||||
|
||||
["source","java",subs="attributes,callouts,macros"]
|
||||
--------------------------------------------------
|
||||
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-field-mapping-request-local]
|
||||
--------------------------------------------------
|
||||
<1> The `local` flag (defaults to `false`) controls whether the aliases need
|
||||
to be looked up in the local cluster state or in the cluster state held by
|
||||
the elected master node
|
||||
|
||||
[[java-rest-high-get-field-mappings-sync]]
|
||||
==== Synchronous Execution
|
||||
|
||||
["source","java",subs="attributes,callouts,macros"]
|
||||
--------------------------------------------------
|
||||
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-field-mapping-execute]
|
||||
--------------------------------------------------
|
||||
|
||||
[[java-rest-high-get-field-mapping-async]]
|
||||
==== Asynchronous Execution
|
||||
|
||||
The asynchronous execution of a get mappings request requires both the
|
||||
`GetFieldMappingsRequest` instance and an `ActionListener` instance to be passed to
|
||||
the asynchronous method:
|
||||
|
||||
["source","java",subs="attributes,callouts,macros"]
|
||||
--------------------------------------------------
|
||||
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-field-mapping-execute-async]
|
||||
--------------------------------------------------
|
||||
<1> The `GetFieldMappingsRequest` to execute and the `ActionListener` to use when the execution completes
|
||||
|
||||
The asynchronous method does not block and returns immediately. Once it is
|
||||
completed the `ActionListener` is called back using the `onResponse` method if
|
||||
the execution successfully completed or using the `onFailure` method if it
|
||||
failed.
|
||||
|
||||
A typical listener for `GetMappingsResponse` looks like:
|
||||
|
||||
["source","java",subs="attributes,callouts,macros"]
|
||||
--------------------------------------------------
|
||||
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-field-mapping-execute-listener]
|
||||
--------------------------------------------------
|
||||
<1> Called when the execution is successfully completed. The response is provided as an argument
|
||||
<2> Called in case of failure. The raised exception is provided as an argument
|
||||
|
||||
[[java-rest-high-get-field-mapping-response]]
|
||||
==== Get Field Mappings Response
|
||||
|
||||
The returned `GetFieldMappingsResponse` allows to retrieve information about the
|
||||
executed operation as follows:
|
||||
|
||||
["source","java",subs="attributes,callouts,macros"]
|
||||
--------------------------------------------------
|
||||
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-field-mapping-response]
|
||||
--------------------------------------------------
|
||||
<1> Returning all requested indices fields' mappings
|
||||
<2> Retrieving the mappings for a particular index and type
|
||||
<3> Getting the mappings metadata for the `message` field
|
||||
<4> Getting the full name of the field
|
||||
<5> Getting the mapping source of the field
|
||||
|
|
@ -77,6 +77,7 @@ Index Management::
|
|||
|
||||
Mapping Management::
|
||||
* <<java-rest-high-put-mapping>>
|
||||
* <<java-rest-high-get-field-mappings>>
|
||||
|
||||
Alias Management::
|
||||
* <<java-rest-high-update-aliases>>
|
||||
|
@ -98,6 +99,7 @@ include::indices/force_merge.asciidoc[]
|
|||
include::indices/rollover.asciidoc[]
|
||||
include::indices/put_mapping.asciidoc[]
|
||||
include::indices/get_mappings.asciidoc[]
|
||||
include::indices/get_field_mappings.asciidoc[]
|
||||
include::indices/update_aliases.asciidoc[]
|
||||
include::indices/exists_alias.asciidoc[]
|
||||
include::indices/get_alias.asciidoc[]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue