I'm trying to parameterize _source in a search template but I'm encountering an error.
This is my template:
PUT _scripts/stored-script
{
"script": {
"lang": "mustache",
"source": {
"_source": "{{#toJson}}fields{{/toJson}}"
}
}
}
GET myIndex/_search/template
{
"id": "stored-script",
"params": {
"fields": ["test", "title"]
}
}
I'm getting the following error:
{
"error" : {
"root_cause" : [
{
"type" : "json_parse_exception",
"reason" : "Unexpected character ('t' (code 116)): was expecting comma to separate Object entries\n at [Source: (StringReader); line: 1, column: 16]"
}
],
"type" : "json_parse_exception",
"reason" : "Unexpected character ('t' (code 116)): was expecting comma to separate Object entries\n at [Source: (StringReader); line: 1, column: 16]"
},
"status" : 400
}
According to this stackoverflow, this should work.
Am I missing something?