Removed array-of-string example from search template

Relates to #19643
This commit is contained in:
Clinton Gormley 2016-07-28 13:49:53 +02:00
parent 105dce0e07
commit 3c639f0673

View File

@ -54,23 +54,16 @@ GET /_search/template
------------------------------------------
[float]
===== Passing an array of strings
===== Converting parameters to JSON
The `{{toJson}}parameter{{/toJson}}` function can be used to convert parameters
like maps and array to their JSON representation:
[source,js]
------------------------------------------
GET /_search/template
{
"inline": {
"query": {
"terms": {
"status": [
"{{#status}}",
"{{.}}",
"{{/status}}"
]
}
}
},
"inline": "{ \"query\": { \"terms\": { \"status\": {{#toJson}}status{{/toJson}} }}}",
"params": {
"status": [ "pending", "published" ]
}
@ -82,13 +75,52 @@ which is rendered as:
[source,js]
------------------------------------------
{
"query": {
"terms": {
"status": [ "pending", "published" ]
"query": {
"terms": {
"status": [
"pending",
"published"
]
}
}
}
------------------------------------------
A more complex example substitutes an array of JSON objects:
[source,js]
------------------------------------------
{
"inline": "{\"query\":{\"bool\":{\"must\": {{#toJson}}clauses{{/toJson}} }}}",
"params": {
"clauses": [
{ "term": "foo" },
{ "term": "bar" }
]
}
}
------------------------------------------
which is rendered as:
[source,js]
------------------------------------------
{
"query" : {
"bool" : {
"must" : [
{
"term" : "foo"
},
{
"term" : "bar"
}
]
}
}
}
------------------------------------------
[float]
===== Concatenating array of values
@ -223,45 +255,6 @@ for `end`:
}
------------------------------------------
[float]
===== Converting parameters to JSON
The `{{toJson}}parameter{{/toJson}}` function can be used to convert parameters
like maps and array to their JSON representation:
[source,js]
------------------------------------------
{
"inline": "{\"query\":{\"bool\":{\"must\": {{#toJson}}clauses{{/toJson}} }}}",
"params": {
"clauses": [
{ "term": "foo" },
{ "term": "bar" }
]
}
}
------------------------------------------
which is rendered as:
[source,js]
------------------------------------------
{
"query" : {
"bool" : {
"must" : [
{
"term" : "foo"
},
{
"term" : "bar"
}
]
}
}
}
------------------------------------------
[float]
===== Conditional clauses
@ -330,7 +323,7 @@ We could write the query as:
==================================
As written above, this template is not valid JSON because it includes the
_section_ markers like `{{#line_no}}`. For this reason, the template should
either be stored in a file (see <<pre-registered-templates>>) or, when used
either be stored in a file (see <<pre-registered-templates>>) or, when used
via the REST API, should be written as a string:
[source,js]
@ -467,7 +460,7 @@ This call will return the rendered template:
------------------------------------------
<1> `status` array has been populated with values from the `params` object.
File and indexed templates can also be rendered by replacing `inline` with
File and indexed templates can also be rendered by replacing `inline` with
`file` or `id` respectively. For example, to render a file template
[source,js]