mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-04-24 23:27:25 -04:00
Add get mappings support to high-level rest client (#30889)
This adds support for the get mappings API to the high level rest client. Relates to #27205
This commit is contained in:
parent
f94a75778c
commit
b22a055bcf
12 changed files with 653 additions and 53 deletions
80
docs/java-rest/high-level/indices/get_mappings.asciidoc
Normal file
80
docs/java-rest/high-level/indices/get_mappings.asciidoc
Normal file
|
@ -0,0 +1,80 @@
|
|||
[[java-rest-high-get-mappings]]
|
||||
=== Get Mappings API
|
||||
|
||||
[[java-rest-high-get-mappings-request]]
|
||||
==== Get Mappings Request
|
||||
|
||||
A `GetMappingsRequest` can have an optional list of indices and optional list of types:
|
||||
|
||||
["source","java",subs="attributes,callouts,macros"]
|
||||
--------------------------------------------------
|
||||
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-mapping-request]
|
||||
--------------------------------------------------
|
||||
<1> An empty request that will return all indices and types
|
||||
<2> Setting the indices to fetch mapping for
|
||||
<3> The types 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-mapping-request-masterTimeout]
|
||||
--------------------------------------------------
|
||||
<1> Timeout to connect to the master node as a `TimeValue`
|
||||
<2> Timeout to connect to the master node as a `String`
|
||||
|
||||
["source","java",subs="attributes,callouts,macros"]
|
||||
--------------------------------------------------
|
||||
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-mapping-request-indicesOptions]
|
||||
--------------------------------------------------
|
||||
<1> Options for expanding indices names
|
||||
|
||||
[[java-rest-high-get-mappings-sync]]
|
||||
==== Synchronous Execution
|
||||
|
||||
["source","java",subs="attributes,callouts,macros"]
|
||||
--------------------------------------------------
|
||||
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-mapping-execute]
|
||||
--------------------------------------------------
|
||||
|
||||
[[java-rest-high-get-mapping-async]]
|
||||
==== Asynchronous Execution
|
||||
|
||||
The asynchronous execution of a get mappings request requires both the
|
||||
`GetMappingsRequest` 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-mapping-execute-async]
|
||||
--------------------------------------------------
|
||||
<1> The `GetMappingsRequest` 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-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-mapping-response]]
|
||||
==== Get Mappings Response
|
||||
|
||||
The returned `GetMappingsResponse` allows to retrieve information about the
|
||||
executed operation as follows:
|
||||
|
||||
["source","java",subs="attributes,callouts,macros"]
|
||||
--------------------------------------------------
|
||||
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-mapping-response]
|
||||
--------------------------------------------------
|
||||
<1> Returning all indices' mappings
|
||||
<2> Retrieving the mappings for a particular index and type
|
||||
<3> Getting the mappings for the "tweet" as a Java Map
|
|
@ -95,6 +95,7 @@ include::indices/clear_cache.asciidoc[]
|
|||
include::indices/force_merge.asciidoc[]
|
||||
include::indices/rollover.asciidoc[]
|
||||
include::indices/put_mapping.asciidoc[]
|
||||
include::indices/get_mappings.asciidoc[]
|
||||
include::indices/update_aliases.asciidoc[]
|
||||
include::indices/exists_alias.asciidoc[]
|
||||
include::indices/put_settings.asciidoc[]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue