Skip to content

Commit

Permalink
Docs: Add note about missing mapping for doc values field (#29036)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rjernst authored Mar 21, 2018
1 parent f938c42 commit 744777a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions docs/reference/modules/scripting/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,17 @@ Doc-values can only return "simple" field values like numbers, dates, geo-
points, terms, etc, or arrays of these values if the field is multi-valued.
It cannot return JSON objects.

[NOTE]
.Missing fields
===================================================
The `doc['field']` will throw an error if `field` is missing from the mappings.
In `painless`, a check can first be done with `doc.containsKey('field')` to guard
accessing the `doc` map. Unfortunately, there is no way to check for the
existence of the field in mappings in an `expression` script.
===================================================

[NOTE]
.Doc values and `text` fields
===================================================
Expand Down

0 comments on commit 744777a

Please sign in to comment.