2013-08-28 19:24:34 -04:00
|
|
|
[[mapping]]
|
|
|
|
= Mapping
|
|
|
|
|
|
|
|
[partintro]
|
|
|
|
--
|
|
|
|
Mapping is the process of defining how a document should be mapped to
|
|
|
|
the Search Engine, including its searchable characteristics such as
|
|
|
|
which fields are searchable and if/how they are tokenized. In
|
2014-01-06 15:58:46 -05:00
|
|
|
Elasticsearch, an index may store documents of different "mapping
|
|
|
|
types". Elasticsearch allows one to associate multiple mapping
|
2013-08-28 19:24:34 -04:00
|
|
|
definitions for each mapping type.
|
|
|
|
|
|
|
|
Explicit mapping is defined on an index/type level. By default, there
|
|
|
|
isn't a need to define an explicit mapping, since one is automatically
|
|
|
|
created and registered when a new type or new field is introduced (with
|
|
|
|
no performance overhead) and have sensible defaults. Only when the
|
|
|
|
defaults need to be overridden must a mapping definition be provided.
|
|
|
|
|
|
|
|
[float]
|
2013-09-30 17:32:00 -04:00
|
|
|
[[all-mapping-types]]
|
2013-08-28 19:24:34 -04:00
|
|
|
=== Mapping Types
|
|
|
|
|
|
|
|
Mapping types are a way to divide the documents in an index into logical
|
|
|
|
groups. Think of it as tables in a database. Though there is separation
|
|
|
|
between types, it's not a full separation (all end up as a document
|
|
|
|
within the same Lucene index).
|
|
|
|
|
|
|
|
Field names with the same name across types are highly recommended to
|
|
|
|
have the same type and same mapping characteristics (analysis settings
|
|
|
|
for example). There is an effort to allow to explicitly "choose" which
|
|
|
|
field to use by using type prefix (`my_type.my_field`), but it's not
|
2014-08-13 09:43:47 -04:00
|
|
|
complete, and there are places where it will never work (like
|
|
|
|
aggregations on the field).
|
2013-08-28 19:24:34 -04:00
|
|
|
|
|
|
|
In practice though, this restriction is almost never an issue. The field
|
|
|
|
name usually ends up being a good indication to its "typeness" (e.g.
|
|
|
|
"first_name" will always be a string). Note also, that this does not
|
|
|
|
apply to the cross index case.
|
|
|
|
|
|
|
|
[float]
|
2013-09-25 12:17:40 -04:00
|
|
|
[[mapping-api]]
|
2013-08-28 19:24:34 -04:00
|
|
|
=== Mapping API
|
|
|
|
|
|
|
|
To create a mapping, you will need the <<indices-put-mapping,Put Mapping
|
|
|
|
API>>, or you can add multiple mappings when you <<indices-create-index,create an
|
|
|
|
index>>.
|
|
|
|
|
|
|
|
[float]
|
2013-09-25 12:17:40 -04:00
|
|
|
[[mapping-settings]]
|
2013-08-28 19:24:34 -04:00
|
|
|
=== Global Settings
|
|
|
|
|
|
|
|
The `index.mapping.ignore_malformed` global setting can be set on the
|
|
|
|
index level to allow to ignore malformed content globally across all
|
2014-01-10 08:50:58 -05:00
|
|
|
mapping types (malformed content example is trying to index a text string
|
2013-08-28 19:24:34 -04:00
|
|
|
value as a numeric type).
|
2014-01-10 08:50:58 -05:00
|
|
|
|
|
|
|
The `index.mapping.coerce` global setting can be set on the
|
|
|
|
index level to coerce numeric content globally across all
|
2015-06-22 17:49:45 -04:00
|
|
|
mapping types (The default setting is true and coercions attempted are
|
2014-01-10 08:50:58 -05:00
|
|
|
to convert strings with numbers into numeric types and also numeric values
|
|
|
|
with fractions to any integer/short/long values minus the fraction part).
|
2015-06-22 17:49:45 -04:00
|
|
|
When the permitted conversions fail in their attempts, the value is considered
|
2014-01-10 08:50:58 -05:00
|
|
|
malformed and the ignore_malformed setting dictates what will happen next.
|
2013-08-28 19:24:34 -04:00
|
|
|
--
|
|
|
|
|
|
|
|
include::mapping/fields.asciidoc[]
|
|
|
|
|
|
|
|
include::mapping/types.asciidoc[]
|
|
|
|
|
|
|
|
include::mapping/date-format.asciidoc[]
|
|
|
|
|
2015-06-22 17:49:45 -04:00
|
|
|
include::mapping/fielddata_formats.asciidoc[]
|
|
|
|
|
2013-08-28 19:24:34 -04:00
|
|
|
include::mapping/dynamic-mapping.asciidoc[]
|
|
|
|
|
|
|
|
include::mapping/meta.asciidoc[]
|
|
|
|
|
2014-06-23 17:36:10 -04:00
|
|
|
include::mapping/transform.asciidoc[]
|