[[indices-put-mapping]] == Put Mapping The PUT mapping API allows you to add a new type to an existing index, or add new fields to an existing type: [source,js] -------------------------------------------------- PUT twitter <1> {} PUT twitter/_mapping/_doc <2> { "properties": { "name": { "type": "text" } } } PUT twitter/_mapping/_doc <3> { "properties": { "email": { "type": "keyword" } } } -------------------------------------------------- // CONSOLE <1> <> called `twitter` without any type mapping. <2> Uses the PUT mapping API to add a new mapping type called `user`. <3> Uses the PUT mapping API to add a new field called `email` to the `user` mapping type. More information on how to define type mappings can be found in the <> section. [float] === Multi-index The PUT mapping API can be applied to multiple indices with a single request. For example, we can update the `twitter-1` and `twitter-2` mappings at the same time: [source,js] -------------------------------------------------- # Create the two indices PUT twitter-1 PUT twitter-2 # Update both mappings PUT /twitter-1,twitter-2/_mapping/_doc <1> { "properties": { "user_name": { "type": "text" } } } -------------------------------------------------- // CONSOLE <1> Note that the indices specified (`twitter-1,twitter-2`) follows <> and wildcard format. NOTE: When updating the `_default_` mapping with the <> API, the new mapping is not merged with the existing mapping. Instead, the new `_default_` mapping replaces the existing one. [[updating-field-mappings]] [float] === Updating field mappings In general, the mapping for existing fields cannot be updated. There are some exceptions to this rule. For instance: * new <> can be added to <> fields. * new <> can be added to existing fields. * the <> parameter can be updated. For example: [source,js] ----------------------------------- PUT my_index <1> { "mappings": { "_doc": { "properties": { "name": { "properties": { "first": { "type": "text" } } }, "user_id": { "type": "keyword" } } } } } PUT my_index/_mapping/_doc { "properties": { "name": { "properties": { "last": { <2> "type": "text" } } }, "user_id": { "type": "keyword", "ignore_above": 100 <3> } } } ----------------------------------- // CONSOLE <1> Create an index with a `first` field under the `name` <> field, and a `user_id` field. <2> Add a `last` field under the `name` object field. <3> Update the `ignore_above` setting from its default of 0. Each <> specifies whether or not its setting can be updated on an existing field.