First of all, this is taken from documentation:
Passing an array of strings
GET /_search/template { "template": { "query": { "terms": { "status": [ "{{#status}}", "{{.}}", "{{/status}}" ] } } }, "params": { "status": [ "pending", "published" ] } }
which is rendered as:
{ "query": { "terms": { "status": [ "pending", "published" ] } }
However, in my scenario I've done exactly the same template (at least I think so), but it produces a slightly different output for me:
.."filter" : {
"bool" : {
"must" : [{
"terms" : {
"myTerms" : [
"{{#myTerms}}",
"{{.}}",
"{{/myTerms}}"
],
"_cache" : true
}
}
]
}
}..
That's how I call it later:
GET /passport/_search/template
{
"template": {
"id": "myTemplate"
},
"params": {
"myTerms": ["1", "2"]
}
}
However it's rendered as:
.."myTerms" : ["", "1", "2", ""]..
That wouldn't a be a issue, but myTerms are stored as integers and I would like to keep it this way (but if only this is solution, then fine, I can live with it), but then query throws exception that it cannot convert "" into integer type, which is expected behaviour
NumberFormatException[For input string: \"\"]
How should I deal with that? I don't want to store my templates as files, I prefer them being indexed.
This SO question was promising: Pass an array of integers to ElasticSeach template but it's not clear and answer didn't solve my issue (I wasn't allowed to store my template like that).
Elasticsearch version used: 1.6.0
Please advice.