浏览代码

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
Ryan Ernst 7 年之前
父节点
当前提交
744777a6a0
共有 1 个文件被更改,包括 11 次插入0 次删除
  1. 11 0
      docs/reference/modules/scripting/fields.asciidoc

+ 11 - 0
docs/reference/modules/scripting/fields.asciidoc

@@ -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.
 points, terms, etc, or arrays of these values if the field is multi-valued.
 It cannot return JSON objects.
 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]
 [NOTE]
 .Doc values and `text` fields
 .Doc values and `text` fields
 ===================================================
 ===================================================