_default_
mappingedit
The default mapping, which will be used as the base mapping for any new
mapping types, can be customised by adding a mapping type with the name
_default_
to an index, either when
creating the index or later on with the
PUT mapping API.
PUT my_index { "mappings": { "_default_": {"_all": { "enabled": false } }, "user": {},
"blogpost": {
"_all": { "enabled": true } } } }
The | |
The | |
The |

When updating the _default_
mapping with the
PUT mapping API, the new mapping is not merged with
the existing mapping. Instead, the new _default_
mapping replaces the
existing one.
While the _default_
mapping can be updated after an index has been created,
the new defaults will only affect mapping types that are created afterwards.
The _default_
mapping can be used in conjunction with
Index templates to control dynamically created types
within automatically created indices:
PUT _template/logging { "template": "logs-*","settings": { "number_of_shards": 1 },
"mappings": { "_default_": { "_all": {
"enabled": false }, "dynamic_templates": [ { "strings": {
"match_mapping_type": "string", "mapping": { "type": "text", "fields": { "raw": { "type": "keyword", "ignore_above": 256 } } } } } ] } } } PUT logs-2015.10.01/event/1 { "message": "error:16" }