Hi,
From the Docs it says that using conditional clauses will cause JSON to be invalid so the JSON would have to be a string but it also says that Pre-registered templates can be used instead with no note of it needing to be converted to a string.
Am I misinterpreting this? If not, how is it possible to use a pre-registered template with conditional clauses? Each time I try and create a template I get the following in response:
{
"error": {
"root_cause": [
{
"type": "parsing_exception",
"reason": "[stored script source] failed to parse field [source]",
"line": 6,
"col": 26
}
],
"type": "parsing_exception",
"reason": "[stored script source] failed to parse field [source]",
"line": 6,
"col": 26,
"caused_by": {
"type": "unchecked_i_o_exception",
"reason": "com.fasterxml.jackson.core.JsonParseException: Unexpected character ('{' (code 123)): was expecting double-quote to start field name\n at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@2d9b1399; line: 7, column: 20]",
"caused_by": {
"type": "json_parse_exception",
"reason": "Unexpected character ('{' (code 123)): was expecting double-quote to start field name\n at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@2d9b1399; line: 7, column: 20]"
}
}
},
"status": 400
}
And as an example JSON I am using the following:
POST _scripts/test
{
"script": {
"lang": "mustache",
"source": {
"query": {
"match": {
{{#something}}
"title": "{{query_string}}"
{{/something}}
}
}
}
}
}
Any help with this would be much appreciated, Thanks.