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,9 +75,48 @@ which is rendered as:
[source,js]
------------------------------------------
{
"query": {
"query": {
"terms": {
"status": [ "pending", "published" ]
"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"
}
]
}
}
}
------------------------------------------
@ -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