Cannot parse numeric values in a search template

Fx. if I take the example from Elasticsearch Reference [7.9] » REST APIs » Search APIs » Search Template and render it I get

POST _render/template
{
  "source" : {
    "query": { "match" : { "{{my_field}}" : "{{my_value}}" } },
    "size" : "{{my_size}}"
  },
  "params" : {
    "my_field" : "message",
    "my_value" : "foo",
    "my_size" : 5
  }
}

Becomes

{
  "template_output" : {
    "query" : {
      "match" : {
        "message" : "foo"
      }
    },
    "size" : "5"
  }
}

As you can see the INTEGER 5 becomes the string "5".

So document is a bit misleading as it is implied it can handle numeric values.

The only way around this I can think of is to drop working with JSON and turn it into a string (mustache and JSON don't really mix).

Any other options?

Hey Bjarne,

Indeed the documentation you referred to is not fully accurate and we'll fix that (thanks for pointing out!).

One way to workaround the issue you've mentioned is to write the query as a string, this way you can refer to {{my_size}} without double-quotes, which will produce an integer, without breaking JSON syntax. For instance:

POST _render/template
{
  "source" : "{ \"query\": { \"match\" : { \"{{my_field}}\" : \"{{my_value}}\" } }, \"size\" : {{my_size}} }",
  "params" : {
    "my_field" : "message",
    "my_value" : "foo",
    "my_size" : 5
  }
}

Best