I've been trying to create a template, but I am having some trouble with the mustache rendering.
On the page: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html, you mention how to use a pre-registered template, that is what I wanted to do. It doesn't really work and the output is very minimal, such as "Unexpected ']'".
I thought I'd start with one of you examples and then call the REST endpoint /_render/template
So this one:
{
"inline": {
"query": {
"terms": {
"status": [
"{{#status}}",
"{{.}}",
"{{/status}}"
]
}
}
},
"params": {
"status": [ "pending", "published" ]
}
}
Have you tried rendering this?
It is supposed to give this output:
{
"template_output": {
"query": {
"terms": {
"status": [
"pending",
"published"
]
}
}
}
}
but I get:
{
"template_output": {
"query": {
"terms": {
"status": [
"",
"pending",
"",
"published",
""
]
}
}
}
}
Now if my status would never be "", then this query would work, but it would not be what I expected?
I am running Elastic Search 2.1.0.
This question was asked and dismissed in topic: Search template creates unnecessary empty strings in arrays
I am not showing my own example.
I am using the examples from your own reference guide, so that I won't confuse the issue with my own failed attempts.
Kind regards, Martin.