From 6394629b99b991d25eaf92e215d9d4a358ecfabf Mon Sep 17 00:00:00 2001 From: James Rodewig <40268737+jrodewig@users.noreply.github.com> Date: Wed, 16 Sep 2020 10:38:56 -0400 Subject: [PATCH] [DOCS] Document `toJSON` function for role query (#62257) (#62462) --- .../authorization/role-templates.asciidoc | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/x-pack/docs/en/security/authorization/role-templates.asciidoc b/x-pack/docs/en/security/authorization/role-templates.asciidoc index d856c2b115e..b222fa6224f 100644 --- a/x-pack/docs/en/security/authorization/role-templates.asciidoc +++ b/x-pack/docs/en/security/authorization/role-templates.asciidoc @@ -66,4 +66,27 @@ POST /_security/role/example2 } ] } --------------------------------------------------- \ No newline at end of file +-------------------------------------------------- + +If your metadata field contains an object or array, you can access it using the +`{{#toJson}}parameter{{/toJson}}` function. + +[source,console] +---- +POST /_security/role/example3 +{ + "indices" : [ + { + "names" : [ "my-index-000001" ], + "privileges" : [ "read" ], + "query" : { + "template" : { + "source" : { + "terms" : { "group.statuses" : "{{#toJson}}_user.metadata.statuses{{/toJson}}" } + } + } + } + } + ] +} +----