The mapper module acts as a registry for the type mapping definitions added to an index either when creating it or by using the put mapping api. It also handles the dynamic mapping support for types that have no explicit mappings pre defined. For more information about mapping definitions, check out the mapping section.
New types and new fields within types can be added dynamically just
by indexing a document. When Elasticsearch encounters a new type,
it creates the type using the default
mapping (see below).
When it encounters a new field within a type, it autodetects the datatype that the field contains and adds it to the type mapping automatically.
See [mapping-dynamic-mapping] for details of how to control and configure dynamic mapping.
When a new type is created (at index creation time,
using the put-mapping
API or just by indexing a
document into it), the type uses the default
mapping as its basis. Any
mapping specified in the create-index
or
put-mapping
request override values set in the
default
mapping.
The default mapping definition is a plain mapping definition that is embedded within ElasticSearch:
{
_default_ : {
}
}
Pretty short, isn’t it? Basically, everything is `default`ed, including the dynamic nature of the root object mapping which allows new fields to be added automatically.
The built-in default mapping definition can be overridden in several ways. A
default
mapping can be specified when creating a new index, or the global
default
mapping (for all indices) can be configured by creating a file
called config/default-mapping.json
. (This location can be changed with
the index.mapper.default_mapping_location
setting.)
Dynamic creation of mappings for unmapped types can be completely
disabled by setting index.mapper.dynamic
to false
.