# How to create a new search template through node js client

**URL:** https://discuss.elastic.co/t/how-to-create-a-new-search-template-through-node-js-client/283216
**Category:** Elasticsearch
**Tags:** language-clients
**Created:** [September 2, 2021, 8:41pm UTC](https://discuss.elastic.co/t/how-to-create-a-new-search-template-through-node-js-client/283216 "2021-09-02T20:41:50Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Gustavo\_Leite\_Silvan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gustavo_leite_silvan/32/94116_2.png) [@Gustavo\_Leite\_Silvan](https://discuss.elastic.co/u/Gustavo_Leite_Silvan)
#### Post date: [September 2, 2021, 8:41pm UTC](https://discuss.elastic.co/t/how-to-create-a-new-search-template-through-node-js-client/283216/1 "2021-09-02T20:41:50Z")

</div>

I'm using Javascript client. Trying to create search templates through it, but didn't found the method to do it.

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [September 3, 2021, 3:10pm UTC](https://discuss.elastic.co/t/how-to-create-a-new-search-template-through-node-js-client/283216/2 "2021-09-03T15:10:12Z")

</div>

Use the `putScript` API to create a search template (which is nothing else than a script). [API Reference | Elasticsearch Node.js client [7.x] | Elastic](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference.html#_putscript)

Then the [searchTemplate](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference.html#_searchtemplate) should be the way to go.

---

<div class="post-metadata">

### Author: ![Gustavo\_Leite\_Silvan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gustavo_leite_silvan/32/94116_2.png) [@Gustavo\_Leite\_Silvan](https://discuss.elastic.co/u/Gustavo_Leite_Silvan)
#### Post date: [September 3, 2021, 8:08pm UTC](https://discuss.elastic.co/t/how-to-create-a-new-search-template-through-node-js-client/283216/3 "2021-09-03T20:08:47Z")

</div>

Thanks

---

<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: [October 1, 2021, 8:09pm UTC](https://discuss.elastic.co/t/how-to-create-a-new-search-template-through-node-js-client/283216/4 "2021-10-01T20:09:08Z")

</div>

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