From fcb8331edded0b1c8640dfff4af451cce5b18b00 Mon Sep 17 00:00:00 2001 From: Sherry Ger Date: Wed, 13 Dec 2023 14:30:19 -0800 Subject: [PATCH] Update search-template.asciidoc The example using the inverted section in the list topic does not produce a query with the correct syntax, https://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html#search-template-lists Fix the example so it creates the correct query. --- .../search/search-your-data/search-template.asciidoc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/reference/search/search-your-data/search-template.asciidoc b/docs/reference/search/search-your-data/search-template.asciidoc index 9fb6ee85ffcca..337a4259a7800 100644 --- a/docs/reference/search/search-your-data/search-template.asciidoc +++ b/docs/reference/search/search-your-data/search-template.asciidoc @@ -853,14 +853,16 @@ PUT _scripts/my-search-template { "script": { "lang": "mustache", - "source": { + "source": + """ + { "query":{ "multi-match":{ "query": "{{query_string}}", - "fields": """[{{#text_fields}}{{user_name}}{{^last}},{{/last}}{{/text_fields}}]""" + "fields": [{{#text_fields}}"{{user_name}}"{{^last}},{{/last}}{{/text_fields}}] } } - } + }""" } } ---- @@ -897,7 +899,7 @@ When rendered the template outputs: "query": { "multi-match": { "query": "My string", - "fields": "[John,kimchy]" + "fields": ["John","kimchy"] } } }