| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 | [[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/_mapping/tweet' -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 queriesQueries and filters can refer to fields that don't exist in a mapping. Whether thisis allowed is controlled by the `index.query.parse.allow_unmapped_fields` setting.This setting defaults to `true`. Setting it to `false` will disallow the usage ofunmapped fields in queries.When registering a new <<search-percolate,percolator query>> or creatinga <<filtered,filtered alias>> then the `index.query.parse.allow_unmapped_fields` settingis forcefully overwritten to disallowed unmapped fields.
 |