---
"Template query":

  - do:
      index:
        index:  test
        type:   testtype
        id:     1
        body:   { "text": "value1" }
  - do:
      index:
        index:  test
        type:   testtype
        id:     2
        body:   { "text": "value2 value3" }
  - do:
      indices.refresh: {}

  - do:
      search:
        body: { "query": { "template": { "query": { "term": { "text": { "value": "{{template}}" } } }, "params": { "template": "value1" } } } }

  - match: { hits.total: 1 }

  - do:
      search: 
        body: { "query": { "template": { "query": {"match_{{template}}": {}}, "params" : { "template" : "all" } } } }

  - match: { hits.total: 2 }

  - do:
      search:
        body: { "query": { "template": { "query": "{ \"term\": { \"text\": { \"value\": \"{{template}}\" } } }", "params": { "template": "value1" } } } }

  - match: { hits.total: 1 }

  - do:
      search:
        body: { "query": { "template": { "query": "{\"match_{{template}}\": {}}", "params" : { "template" : "all" } } } }

  - match: { hits.total: 2 }

  - do:
      search:
        body: { "query": { "template": { "query": "{\"query_string\": { \"query\" : \"{{query}}\" }}", "params" : { "query" : "text:\"value2 value3\"" } } } }


  - match: { hits.total: 1 }