Skip to content

Commit 62e2778

Browse files
jrodewigliebeslied
andauthored
[DOCS] Edit validation section of dynamic templates docs (#57510) (#57557)
Co-authored-by: Jess <[email protected]>
1 parent 474a3fc commit 62e2778

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

docs/reference/mapping/dynamic/templates.asciidoc

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ dynamically added fields based on:
99
* the full dotted path to the field, with <<path-match-unmatch,`path_match` and `path_unmatch`>>.
1010

1111
The original field name `{name}` and the detected datatype
12-
`{dynamic_type`} <<template-variables,template variables>> can be used in
12+
`{dynamic_type}` <<template-variables,template variables>> can be used in
1313
the mapping specification as placeholders.
1414

1515
IMPORTANT: Dynamic field mappings are only added when a field contains a
1616
concrete value -- not `null` or an empty array. This means that if the
17-
`null_value` option is used in a `dynamic_template`, it will only be applied
18-
after the first document with a concrete value for the field has been
17+
`null_value` option is used in a `dynamic_template`, it will only be applied
18+
after the first document with a concrete value for the field has been
1919
indexed.
2020

2121
Dynamic templates are specified as an array of named objects:
@@ -37,19 +37,20 @@ Dynamic templates are specified as an array of named objects:
3737
<2> The match conditions can include any of : `match_mapping_type`, `match`, `match_pattern`, `unmatch`, `path_match`, `path_unmatch`.
3838
<3> The mapping that the matched field should use.
3939

40-
If a provided mapping contains an invalid mapping snippet then that results in
41-
a validation error. Validation always occurs when applying the dynamic template
42-
at index time or in most cases when updating the dynamic template.
40+
If a provided mapping contains an invalid mapping snippet, a validation error
41+
is returned. Validation occurs when applying the dynamic template at index time,
42+
and, in most cases, when the dynamic template is updated. Providing an invalid mapping
43+
snippet may cause the update or validation of a dynamic template to fail under certain conditions:
4344

44-
Whether updating the dynamic template fails when supplying an invalid mapping snippet depends on the following:
45-
* If no `match_mapping_type` has been specified then if the template is valid with one predefined mapping type then
46-
the mapping snippet is considered valid. However if at index time a field that matches with the template is indexed
47-
as a different type then an validation error will occur at index time instead. For example configuring a dynamic
48-
template with no `match_mapping_type` is considered valid as string type, but at index time a field that matches with
49-
the dynamic template is indexed as a long, then at index time a validation error may still occur.
50-
* If the `{{name}}` placeholder is used in the mapping snippet then the validation is skipped when updating
51-
the dynamic template. This is because the field name is unknown at that time. The validation will then occur
52-
when applying the template at index time.
45+
* If no `match_mapping_type` has been specified but the template is valid for at least one predefined mapping type,
46+
the mapping snippet is considered valid. However, a validation error is returned at index time if a field matching
47+
the template is indexed as a different type. For example, configuring a dynamic template with no `match_mapping_type`
48+
is considered valid as string type, but if a field matching the dynamic template is indexed as a long, a validation
49+
error is returned at index time.
50+
51+
* If the `{{name}}` placeholder is used in the mapping snippet, validation is skipped when updating the dynamic
52+
template. This is because the field name is unknown at that time. Instead, validation occurs when the template is applied
53+
at index time.
5354

5455
Templates are processed in order -- the first matching template wins. When
5556
putting new dynamic templates through the <<indices-put-mapping, put mapping>> API,
@@ -59,16 +60,16 @@ reordered or deleted after they were initially added.
5960
[[match-mapping-type]]
6061
==== `match_mapping_type`
6162

62-
The `match_mapping_type` is the datatype detected by the json parser. Since
63-
JSON doesn't allow to distinguish a `long` from an `integer` or a `double` from
63+
The `match_mapping_type` is the datatype detected by the JSON parser. Since
64+
JSON doesn't distinguish a `long` from an `integer` or a `double` from
6465
a `float`, it will always choose the wider datatype, i.e. `long` for integers
6566
and `double` for floating-point numbers.
6667

6768
The following datatypes may be automatically detected:
6869

6970
- `boolean` when `true` or `false` are encountered.
70-
- `date` when <<date-detection,date detection>> is enabled and a string is
71-
found that matches any of the configured date formats.
71+
- `date` when <<date-detection,date detection>> is enabled and a string matching
72+
any of the configured date formats is found.
7273
- `double` for numbers with a decimal part.
7374
- `long` for numbers without a decimal part.
7475
- `object` for objects, also called hashes.

0 commit comments

Comments
 (0)