From 9fe36b543467b360c4c033ce957982f1507a5d22 Mon Sep 17 00:00:00 2001 From: Julie Tibshirani Date: Mon, 29 Apr 2019 15:01:36 -0700 Subject: [PATCH 1/2] Clarify that path_match also considers object fields. The `path_match` and `path_unmatch` parameters in dynamic templates match on object fields in addition to leaf fields. This is not obvious and can cause surprising errors when a template is meant for a leaf field, but there are object fields that match. This PR adds a note to the docs to describe the current behavior. --- .../mapping/dynamic/templates.asciidoc | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/docs/reference/mapping/dynamic/templates.asciidoc b/docs/reference/mapping/dynamic/templates.asciidoc index 8598eab412e79..0398ea59780ca 100644 --- a/docs/reference/mapping/dynamic/templates.asciidoc +++ b/docs/reference/mapping/dynamic/templates.asciidoc @@ -198,14 +198,37 @@ PUT my_index PUT my_index/_doc/1 { "name": { - "first": "Alice", - "middle": "Mary", - "last": "White" + "first": "John", + "middle": "Winston", + "last": "Lennon" } } -------------------------------------------------- // CONSOLE +Note that the `path_match` and `path_unmatch` parameters match on object paths +in addition to leaf fields. As an example, indexing the following document will +result in an error because the `path_match` setting also matches the object +field `name.title`: + +[source,js] +-------------------------------------------------- +PUT my_index/_doc/2 +{ + "name": { + "first": "Paul", + "last": "McCartney", + "title": { + "value": "Sir", + "category": "order of chivalry" + } + } +} +-------------------------------------------------- +// CONSOLE +// TEST[continued] +// TEST[catch:bad_request] + [[template-variables]] ==== `{name}` and `{dynamic_type}` From fb7c33d24e872ad1461ec1f86fca24ff69eeb6bd Mon Sep 17 00:00:00 2001 From: Julie Tibshirani Date: Mon, 6 May 2019 11:30:07 -0700 Subject: [PATCH 2/2] More clearly explain why the example will produce an error. --- docs/reference/mapping/dynamic/templates.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/reference/mapping/dynamic/templates.asciidoc b/docs/reference/mapping/dynamic/templates.asciidoc index 0398ea59780ca..916759799d1ec 100644 --- a/docs/reference/mapping/dynamic/templates.asciidoc +++ b/docs/reference/mapping/dynamic/templates.asciidoc @@ -209,7 +209,7 @@ PUT my_index/_doc/1 Note that the `path_match` and `path_unmatch` parameters match on object paths in addition to leaf fields. As an example, indexing the following document will result in an error because the `path_match` setting also matches the object -field `name.title`: +field `name.title`, which can't be mapped as text: [source,js] --------------------------------------------------