When I put "explain=true" into a search template (as a parameter, so we can turn it on and off) it does not work. I see a similar problem long ago in .net...this is version 8.14.
Following is simple kibana demonstrating the issue:
PUT /my-index-000001
POST /my-index-000001/_doc
{
"@timestamp": "2099-11-15T13:12:00",
"message": "explain bug",
"user": {
"id": "randall"
}
}
PUT _scripts/my-search-template
{
"script": {
"lang": "mustache",
"source": {
"query": {
"match": {
"message": "{{query_string}}"
}
},
"from": "{{from}}",
"size": "{{size}}",
"explain": "{{exp}}"
},
"params": {
"query_string": "My query string",
"exp" : true
}
}
}
POST _render/template
{
"id": "my-search-template",
"params": {
"query_string": "bug",
"from": 0,
"size": 10,
"exp":"true"
}
}
GET my-index-000001/_search/template
{ /* finds one document but no explanation is given */
"id": "my-search-template",
"params": {
"query_string": "bug",
"from": 0,
"size": 10,
"exp":true
}
}
GET my-index-000001/_search
{ /* this works, explanation is offered */
"query": {
"match": {
"message": "bug"
}
},
"from": "0",
"size": "10",
"explain": "true"
}