[[indices-get-mapping]]
=== Get mapping API
++++
<titleabbrev>Get mapping</titleabbrev>
++++

Retrieves <<mapping,mapping definitions>> for one or more indices. For data
streams, the API retrieves mappings for the stream's backing indices.

[source,console]
--------------------------------------------------
GET /my-index-000001/_mapping
--------------------------------------------------
// TEST[setup:my_index]

NOTE: Before 7.0.0, the 'mappings' definition used to include a type name. Although mappings
in responses no longer contain a type name by default, you can still request the old format
through the parameter `include_type_name`. For more details, please see <<removal-of-types>>.


[[get-mapping-api-request]]
==== {api-request-title}

`GET /_mapping`

`GET /<target>/_mapping`

[[get-mapping-api-prereqs]]
==== {api-prereq-title}

* If the {es} {security-features} are enabled, you must have the
`view_index_metadata` or `manage` <<privileges-list-indices,index privilege>>
for the target data stream, index, or alias.

[[get-mapping-api-path-params]]
==== {api-path-parms-title}

`<target>`::
(Optional, string) Comma-separated list of data streams, indices, and aliases
used to limit the request. Supports wildcards (`*`). To target all data streams
and indices, omit this parameter or use `*` or `_all`.

[[get-mapping-api-query-params]]
==== {api-query-parms-title}

include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=allow-no-indices]
+
Defaults to `true`.

include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=expand-wildcards]
+
Defaults to `open`.

include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=include-type-name]

include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=index-ignore-unavailable]

include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=local]

include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=master-timeout]


[[get-mapping-api-example]]
==== {api-examples-title}

[[get-mapping-api-multi-ex]]
===== Multiple data streams and indices

The get mapping API can be used to get more than one data stream or index with a
single call. General usage of the API follows the following syntax:
`host:port/<target>/_mapping` where `<target>` can accept a comma-separated
list of names. To get mappings for all data streams and indices in a cluster, use `_all` or `*` for `<target>`
or omit the `<target>` parameter.
The following are some examples:

[source,console]
--------------------------------------------------
GET /my-index-000001,my-index-000002/_mapping
--------------------------------------------------
// TEST[s/^/PUT my-index-000001\nPUT my-index-000002\n/]

If you want to get mappings of all indices in a cluster, the following
examples are equivalent:

[source,console]
--------------------------------------------------
GET /*/_mapping

GET /_all/_mapping

GET /_mapping
--------------------------------------------------
// TEST[setup:my_index]
