Update field mappings

POST /{index}/_mapping

Adds new fields to an existing data stream or index. You can also use this API to change the search settings of existing fields. For data streams, these changes are applied to all backing indices by default.

Path parameters

  • index string | array[string] Required

    A comma-separated list of index names the mapping should be added to (supports wildcards); use _all or omit to add the mapping on all indices.

Query parameters

  • 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 | array[string]

    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. Valid values are: all, open, closed, hidden, none.

  • If false, the request returns an error if it targets a missing or closed index.

  • 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.

  • timeout string

    Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error.

  • If true, the mappings are applied only to the current write index for the target.

application/json

Body Required

Responses

  • 200 application/json
    Hide response attributes Show response attributes object
POST /{index}/_mapping
curl \
 -X POST http://api.example.com/{index}/_mapping \
 -H "Content-Type: application/json" \
 -d '{"date_detection":true,"dynamic":"strict","dynamic_date_formats":["string"],"dynamic_templates":{},"_field_names":{"enabled":true},"_meta":{"key":{}},"numeric_detection":true,"properties":{},"_routing":{"required":true},"_source":{"compress":true,"compress_threshold":"string","enabled":true,"excludes":["string"],"includes":["string"],"mode":"disabled"},"":{"fetch_fields":[{"field":"string","format":"string"}],"format":"string","input_field":"string","target_field":"string","target_index":"string","script":{"source":"string","id":"string","params":{"key":{}},"":"painless","options":{"key":"string"}},"type":"boolean"}}'