# Error while running search templates on ES 5.2.0 Unknown key for a VALUE\_STRING in \[id\]

**URL:** <https://discuss.elastic.co/t/error-while-running-search-templates-on-es-5-2-0-unknown-key-for-a-value-string-in-id/75330>\
**Category:** Elasticsearch\
**Created:** [February 16, 2017, 12:27pm UTC](https://discuss.elastic.co/t/error-while-running-search-templates-on-es-5-2-0-unknown-key-for-a-value-string-in-id/75330 "2017-02-16T12:27:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vikas\_Mestry](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vikas_mestry/32/42301_2.png) [@Vikas\_Mestry](https://discuss.elastic.co/u/Vikas_Mestry)\
**Post date:** [February 16, 2017, 12:27pm UTC](https://discuss.elastic.co/t/error-while-running-search-templates-on-es-5-2-0-unknown-key-for-a-value-string-in-id/75330/1 "2017-02-16T12:27:52Z")

</div>

Hello,

I am trying to run searches using searchtemplates following are the commands i am executing

`curl -XPUT 'localhost:9200/test/' -d '{"settings":{"index":{"number_of_shards":1,"number_of_replicas":0}}}'`

```
curl -XPOST 'localhost:9200/test/testtype/1' -d '{"text":"value1_foo"}'
curl -XPOST 'localhost:9200/test/testtype/2?refresh=true' -d '{"text":"value2_foo value3_foo"}'
curl -XPOST 'localhost:9200/test/_refresh'

curl -XPUT 'localhost:9200/_search/template/my_template2' -d '{
  "template": {
    "query": {
      "match": {
        "text" : "{{my_value}}"
      }
    }
  }
}'
curl -XPOST 'localhost:9200/_refresh'

curl -XGET 'localhost:9200/test/_search/template' -d '{
  "template": {
    "id": "my_template2"
  },
  "params": {
    "my_value": "value1_foo"
  }
}'

```

`{"error":{"root_cause":[{"type":"parsing_exception","reason":"Unknown key for a VALUE_STRING in [id].","line":1,"col":7}],"type":"parsing_exception","reason":"Unknown key for a VALUE_STRING in [id].","line":1,"col":7},"status":400}`

Any helps appreciated.

---

<div class="post-metadata">

**Author:** ![danielmitterdorfer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danielmitterdorfer/32/110510_2.png) [@danielmitterdorfer](https://discuss.elastic.co/u/danielmitterdorfer)\
**Post date:** [February 17, 2017, 9:51am UTC](https://discuss.elastic.co/t/error-while-running-search-templates-on-es-5-2-0-unknown-key-for-a-value-string-in-id/75330/2 "2017-02-17T09:51:55Z")

</div>

Hi @Vikas_Mestry,

the syntax of the last statement is wrong. It should be:

```auto
curl -XGET "http://localhost:9200/test/_search/template" -d'
{
   "id": "my_template",
   "params": {
      "my_value": "value1_foo"
   }
}'

```

Daniel

---

<div class="post-metadata">

**Author:** ![Vikas\_Mestry](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vikas_mestry/32/42301_2.png) [@Vikas\_Mestry](https://discuss.elastic.co/u/Vikas_Mestry)\
**Post date:** [February 17, 2017, 10:06am UTC](https://discuss.elastic.co/t/error-while-running-search-templates-on-es-5-2-0-unknown-key-for-a-value-string-in-id/75330/3 "2017-02-17T10:06:28Z")

</div>

thanks @danielmitterdorfer that worked, my bad i should have read this in depth  
[https://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html#pre-registered-templates](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html#pre-registered-templates)

---

<div class="post-metadata">

**Author:** ![danielmitterdorfer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danielmitterdorfer/32/110510_2.png) [@danielmitterdorfer](https://discuss.elastic.co/u/danielmitterdorfer)\
**Post date:** [February 17, 2017, 10:09am UTC](https://discuss.elastic.co/t/error-while-running-search-templates-on-es-5-2-0-unknown-key-for-a-value-string-in-id/75330/4 "2017-02-17T10:09:39Z")

</div>

Hi @Vikas_Mestry,

no worries. That happens to all of us. 🙂

Daniel

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 17, 2017, 10:09am UTC](https://discuss.elastic.co/t/error-while-running-search-templates-on-es-5-2-0-unknown-key-for-a-value-string-in-id/75330/5 "2017-03-17T10:09:48Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
