Skip to content

Commit ac0f281

Browse files
committed
Docs: Add note about missing mapping for doc values field (#29036)
This commit adds a documentation note about the behavior when trying to access docvalues for a field which does not exist in mappings. closes #22056
1 parent 13ead2f commit ac0f281

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

docs/reference/modules/scripting/fields.asciidoc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,17 @@ Doc-values can only return "simple" field values like numbers, dates, geo-
115115
points, terms, etc, or arrays of these values if the field is multi-valued.
116116
It cannot return JSON objects.
117117

118+
[NOTE]
119+
.Missing fields
120+
===================================================
121+
122+
The `doc['field']` will throw an error if `field` is missing from the mappings.
123+
In `painless`, a check can first be done with `doc.containsKey('field')` to guard
124+
accessing the `doc` map. Unfortunately, there is no way to check for the
125+
existence of the field in mappings in an `expression` script.
126+
127+
===================================================
128+
118129
[NOTE]
119130
.Doc values and `text` fields
120131
===================================================

0 commit comments

Comments
 (0)