| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 | [[mapping-dynamic-mapping]]== Dynamic MappingDefault mappings allow generic mapping definitions to be automatically appliedto types that do not have mappings predefined. This is mainly donethanks to the fact that the<<mapping-object-type,object mapping>> andnamely the <<mapping-root-object-type,rootobject mapping>> allow for schema-less dynamic addition of unmappedfields.The default mapping definition is a plain mapping definition that isembedded within the distribution:[source,js]--------------------------------------------------{    "_default_" : {    }}--------------------------------------------------Pretty short, isn't it? Basically, everything is defaulted, especially thedynamic nature of the root object mapping. The default mappingdefinition can be overridden in several manners. The simplest manner isto simply define a file called `default-mapping.json` and to place itunder the `config` directory (which can be configured to exist in adifferent location). It can also be explicitly set using the`index.mapper.default_mapping_location` setting.The dynamic creation of mappings for unmapped types can be completelydisabled by setting `index.mapper.dynamic` to `false`.The dynamic creation of fields within a type can be completelydisabled by setting the `dynamic` property of the type to `strict`.Here is a <<indices-put-mapping,Put Mapping>> example thatdisables dynamic field creation for a `tweet`:[source,js]--------------------------------------------------$ curl -XPUT 'http://localhost:9200/twitter/tweet/_mapping' -d '{    "tweet" : {        "dynamic": "strict",        "properties" : {            "message" : {"type" : "string", "store" : true }        }    }}'--------------------------------------------------Here is how we can change the default<<mapping-date-format,date_formats>> used in theroot and inner object types:[source,js]--------------------------------------------------{    "_default_" : {        "dynamic_date_formats" : ["yyyy-MM-dd", "dd-MM-yyyy", "date_optional_time"]    }}--------------------------------------------------[float]=== Unmapped fields in queriescoming[1.4.0]Queries and filters can refer to fields which don't exist in a mapping, exceptwhen registering a new <<search-percolate,percolator query>> or when creatinga <<filtered,filtered alias>>.  In these two cases, any fields referred to inthe query or filter must already exist in the mapping, otherwise there is achance that the wrong field type will be used.This requirement can be disabled by setting`index.query.parse.allow_unmapped_fields` to `true`, in which case you run therisk that your query or filter might not work correctly.
 |