elasticsearch/docs/reference/mapping.asciidoc
2021-01-11 13:50:06 -05:00

92 lines
3.4 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[[mapping]]
= Mapping
[partintro]
--
Mapping is the process of defining how a document, and the fields it contains,
are stored and indexed.
Each document is a collection of fields, which each have their own
<<mapping-types,data type>>. When mapping your data, you create a mapping
definition, which contains a list of fields that are pertinent to the document.
A mapping definition also includes <<mapping-fields,metadata fields>>, like the
`_source` field, which customize how a document's associated metadata is
handled.
Use _dynamic mapping_ and _explicit mapping_ to define your data. Each method
provides different benefits based on where you are in your data journey. For
example, explicitly map fields where you don't want to use the defaults, or to
gain greater control over which fields are created. You can then allow {es} to
add other fields dynamically.
NOTE: Before 7.0.0, the mapping definition included a type name.
{es} 7.0.0 and later no longer accept a _default_ mapping. See <<removal-of-types>>.
.Experiment with mapping options
****
<<runtime-search-request,Define runtime fields in a search request>> to
experiment with different mapping options, and also fix mistakes in your index
mapping values by overriding values in the mapping during the search request.
****
[discrete]
[[mapping-dynamic]]
== Dynamic mapping
<<dynamic-field-mapping,Dynamic mapping>> allows you to experiment with
and explore data when youre just getting started. {es} adds new fields
automatically, just by indexing a document. You can add fields to the top-level
mapping, and to inner <<object,`object`>> and <<nested,`nested`>> fields.
Use <<dynamic-templates,dynamic templates>> to define custom mappings that are
applied to dynamically added fields based on the matching condition.
[discrete]
[[mapping-explicit]]
== Explicit mapping
<<explicit-mapping,Explicit mapping>> allows you to precisely choose how to
define the mapping definition, such as:
* Which string fields should be treated as full text fields.
* Which fields contain numbers, dates, or geolocations.
* The <<mapping-date-format,format>> of date values.
* Custom rules to control the mapping for
<<dynamic-mapping,dynamically added fields>>.
Use <<runtime-mapping-fields,runtime fields>> to make schema changes without
reindexing. You can use runtime fields in conjunction with indexed fields to
balance resource usage and performance. Your index will be smaller, but with
slower search performance.
[discrete]
[[mapping-limit-settings]]
== Settings to prevent mapping explosion
Defining too many fields in an index can lead to a mapping explosion, which can
cause out of memory errors and difficult situations to recover from.
Consider a situation where every new document inserted
introduces new fields, such as with <<dynamic-mapping,dynamic mapping>>.
Each new field is added to the index mapping, which can become a
problem as the mapping grows.
Use the <<mapping-settings-limit,mapping limit settings>> to limit the number
of field mappings (created manually or dynamically) and prevent documents from
causing a mapping explosion.
--
include::mapping/dynamic-mapping.asciidoc[]
include::mapping/explicit-mapping.asciidoc[]
include::mapping/runtime.asciidoc[]
include::mapping/types.asciidoc[]
include::mapping/fields.asciidoc[]
include::mapping/params.asciidoc[]
include::mapping/mapping-settings-limit.asciidoc[]
include::mapping/removal_of_types.asciidoc[]