Skip to content

Commit 693865e

Browse files
committed
Improve documentation of dynamic mappings. (#30952)
Closes #30939
1 parent 0d89d80 commit 693865e

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

docs/reference/mapping/dynamic/field-mapping.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,6 @@ PUT my_index/_doc/1
135135
}
136136
--------------------------------------------------
137137
// CONSOLE
138-
<1> The `my_float` field is added as a <<number,`double`>> field.
138+
<1> The `my_float` field is added as a <<number,`float`>> field.
139139
<2> The `my_integer` field is added as a <<number,`long`>> field.
140140

docs/reference/mapping/dynamic/templates.asciidoc

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,22 @@ name as an existing template, it will replace the old version.
4646
[[match-mapping-type]]
4747
==== `match_mapping_type`
4848

49-
The `match_mapping_type` matches on the datatype detected by
50-
<<dynamic-field-mapping,dynamic field mapping>>, in other words, the datatype
51-
that Elasticsearch thinks the field should have. Only the following datatypes
52-
can be automatically detected: `boolean`, `date`, `double`, `long`, `object`,
53-
`string`. It also accepts `*` to match all datatypes.
49+
The `match_mapping_type` is the datatype detected by the json parser. Since
50+
JSON doesn't allow to distinguish a `long` from an `integer` or a `double` from
51+
a `float`, it will always choose the wider datatype, ie. `long` for integers
52+
and `double` for floating-point numbers.
53+
54+
The following datatypes may be automatically detected:
55+
56+
- `boolean` when `true` or `false` are encountered.
57+
- `date` when <<date-detection,date detection>> is enabled and a string is
58+
found that matches any of the configured date formats.
59+
- `double` for numbers with a decimal part.
60+
- `long` for numbers without a decimal part.
61+
- `object` for objects, also called hashes.
62+
- `string` for character strings.
63+
64+
`*` may also be used in order to match all datatypes.
5465

5566
For example, if we wanted to map all integer fields as `integer` instead of
5667
`long`, and all `string` fields as both `text` and `keyword`, we

0 commit comments

Comments
 (0)