---
type: api
title: Get mapping definitions
description: **All methods and paths for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/elasticsearch/v8/operation/operation-indices-get-mapping
resource: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/elasticsearch/v8/operation/operation-indices-get-mapping
products:
  - Elasticsearch
---

# Get mapping definitions


## Paths

- `GET` `/{index}/_mapping`
- `GET` `/_mapping`

#### Path parameters

- `index` (union string | string[]) — optional, leave it out to use `/_mapping`
  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`.

## Description

For data streams, the API retrieves mappings for the stream’s backing indices.

## Required authorization

- Index privileges: `view_index_metadata`

## Authentication

- Api key: `Authorization: <value>`
  Elasticsearch APIs support key-based authentication.
  You must create an API key and use the encoded value in the request header.
  For example:
  
  
  ```
  curl -X GET "${ES_URL}/_cat/indices?v=true" \
    -H "Authorization: ApiKey ${API_KEY}"
  ```
  
  To get API keys, use the `/_security/api_key` APIs.
- Basic: `Authorization: Basic <credentials>`
- Bearer: `Authorization: Bearer <token>`
  Elasticsearch APIs support the use of bearer tokens in the `Authorization` HTTP header to authenticate with the API.
  For examples, refer to [Token-based authentication services](https://www.elastic.co/guide/en/elasticsearch/reference/current/token-authentication-services.html)

## Query string parameters

- `allow_no_indices` (boolean · default: true) — optional
  If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indices.
This behavior applies even if the request targets other open indices.
- `expand_wildcards` (string · default: open) — optional
  Type of index that wildcard patterns can match.
If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams.
Supports comma-separated values, such as `open,hidden`.

Supported values include:
  - `all`: Match any data stream or index, including hidden ones.
  - `open`: Match open, non-hidden indices. Also matches any non-hidden data stream.
  - `closed`: Match closed, non-hidden indices. Also matches any non-hidden data stream. Data streams cannot be closed.
  - `hidden`: Match hidden data streams and hidden indices. Must be combined with `open`, `closed`, or `both`.
  - `none`: Wildcard expressions are not accepted.
  Values: `all`, `open`, `closed`, `hidden`, `none`
- `ignore_unavailable` (boolean · default: false) — optional
  If `false`, the request returns an error if it targets a missing or closed index.
- `local` (boolean · default: false) — optional — deprecated
  If `true`, the request retrieves information from the local node only.
- `master_timeout` (string · default: 30s) — optional
  Period to wait for a connection to the master node.
If no response is received before the timeout expires, the request fails and returns an error.

## Response

`application/json`

- `<string>` (object)
  - `item` (object)
    - `all_field` (object)
      - `analyzer` (string)
      - `enabled` (boolean)
      - `omit_norms` (boolean)
      - `search_analyzer` (string)
      - `similarity` (string)
      - `store` (boolean)
      - `store_term_vector_offsets` (boolean)
      - `store_term_vector_payloads` (boolean)
      - `store_term_vector_positions` (boolean)
      - `store_term_vectors` (boolean)
    - `date_detection` (boolean)
    - `dynamic` (enum)
      Values: `strict`, `runtime`, `true`, `false`
    - `dynamic_date_formats` (string[])
    - `dynamic_templates` (string to object[])
    - `_field_names` (object)
      - `enabled` (boolean)
    - `index_field` (object)
      - `enabled` (boolean)
    - `_meta` (object)
    - `numeric_detection` (boolean)
    - `properties` (map string to oneOf)
    - `_routing` (object)
      - `required` (boolean)
    - `_size` (object)
      - `enabled` (boolean)
    - `_source` (object)
      - `compress` (boolean)
      - `compress_threshold` (string)
      - `enabled` (boolean)
      - `excludes` (string[])
      - `includes` (string[])
      - `mode` (enum)
        

Supported values include:
  - `disabled`
  - `stored`
  - `synthetic`: Instead of storing source documents on disk exactly as you send them,
 Elasticsearch can reconstruct source content on the fly upon retrieval.
        Values: `disabled`, `stored`, `synthetic`
    - `runtime` (map string to object)
      Map values (object)
      - `fields` (map string to object)
        For type `composite`
        Map values (object)
        - `type` (enum)
          Values: `boolean`, `composite`, `date`, `double`, `geo_point`, `geo_shape`, `ip`, `keyword`, `long`, `lookup`
      - `fetch_fields` (object[])
        For type `lookup`
        - `field` (string)
        - `format` (string)
      - `format` (string)
        A custom format for `date` type runtime fields.
      - `input_field` (string)
        For type `lookup`
      - `target_field` (string)
        For type `lookup`
      - `target_index` (string)
        For type `lookup`
      - `script` (string)
        Painless script executed at query time.
      - `on_script_error` (enum)
        Values: `fail`, `continue`
      - `type` (enum)
        Field type, which can be: `boolean`, `composite`, `date`, `double`, `geo_point`, `ip`,`keyword`, `long`, or `lookup`.
        Values: `boolean`, `composite`, `date`, `double`, `geo_point`, `geo_shape`, `ip`, `keyword`, `long`, `lookup`
    - `enabled` (boolean)
    - `subobjects` (enum)
      Values: `true`, `false`
    - `_data_stream_timestamp` (object)
      - `enabled` (boolean)
  - `mappings` (object)
    Same fields as `item` in `<string>`
## Code examples

#### Console

```console
GET /books/_mapping
```

#### JavaScript

```javascript
const response = await client.indices.getMapping({
  index: "books",
});
```

#### Python

```python
resp = client.indices.get_mapping(
    index="books",
)
```

#### curl

```curl
curl -X GET "$ELASTICSEARCH_URL/books/_mapping" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY"
```

#### Java

```java
client.indices().getMapping(g -> g
    .index("books")
);
```

#### C#

```c#
var response = await client.Indices
    .GetMappingAsync(d1 => d1
        .Indices(new[] { "books" })
    );
```

#### PHP

```php
$resp = $client->indices()->getMapping([
    "index" => "books",
]);
```

#### Ruby

```ruby
response = client.indices.get_mapping(
  index: "books"
)
```

