2015-08-06 23:24:29 +08:00
|
|
|
[[dynamic-mapping]]
|
2021-01-12 01:31:26 +08:00
|
|
|
== Dynamic mapping
|
2013-08-29 07:24:34 +08:00
|
|
|
|
2021-01-12 01:31:26 +08:00
|
|
|
One of the most important features of {es} is that it tries to get
|
2015-08-06 23:24:29 +08:00
|
|
|
out of your way and let you start exploring your data as quickly as possible.
|
|
|
|
To index a document, you don't have to first create an index, define a mapping
|
|
|
|
type, and define your fields -- you can just index a document and the index,
|
2021-01-12 01:31:26 +08:00
|
|
|
type, and fields will display automatically:
|
2013-08-29 07:24:34 +08:00
|
|
|
|
2019-09-06 22:55:16 +08:00
|
|
|
[source,console]
|
2013-08-29 07:24:34 +08:00
|
|
|
--------------------------------------------------
|
2017-12-15 00:47:53 +08:00
|
|
|
PUT data/_doc/1 <1>
|
2015-08-06 23:24:29 +08:00
|
|
|
{ "count": 5 }
|
2013-08-29 07:24:34 +08:00
|
|
|
--------------------------------------------------
|
2019-09-06 22:55:16 +08:00
|
|
|
|
2017-12-15 00:47:53 +08:00
|
|
|
<1> Creates the `data` index, the `_doc` mapping type, and a field
|
2020-07-08 01:52:10 +08:00
|
|
|
called `count` with data type `long`.
|
2013-08-29 07:24:34 +08:00
|
|
|
|
2017-07-05 18:30:19 +08:00
|
|
|
The automatic detection and addition of new fields is called
|
2021-01-12 01:31:26 +08:00
|
|
|
_dynamic mapping_. The dynamic mapping rules can be customized to suit your
|
2015-08-06 23:24:29 +08:00
|
|
|
purposes with:
|
2013-08-29 07:24:34 +08:00
|
|
|
|
2015-08-06 23:24:29 +08:00
|
|
|
<<dynamic-field-mapping,Dynamic field mappings>>::
|
2013-10-11 02:17:49 +08:00
|
|
|
|
2015-08-06 23:24:29 +08:00
|
|
|
The rules governing dynamic field detection.
|
|
|
|
|
|
|
|
<<dynamic-templates,Dynamic templates>>::
|
2013-10-11 02:17:49 +08:00
|
|
|
|
2015-08-06 23:24:29 +08:00
|
|
|
Custom rules to configure the mapping for dynamically added fields.
|
|
|
|
|
2021-01-12 01:38:09 +08:00
|
|
|
TIP: <<index-templates,Index templates>> allow you to configure the default
|
2015-12-23 00:08:35 +08:00
|
|
|
mappings, settings and aliases for new indices, whether created
|
2015-08-06 23:24:29 +08:00
|
|
|
automatically or explicitly.
|
|
|
|
|
2017-07-05 18:30:19 +08:00
|
|
|
include::dynamic/field-mapping.asciidoc[]
|
2015-08-06 23:24:29 +08:00
|
|
|
|
2017-07-05 18:30:19 +08:00
|
|
|
include::dynamic/templates.asciidoc[]
|