# Can we execute the search template without using client from frontend such as react?

**URL:** https://discuss.elastic.co/t/can-we-execute-the-search-template-without-using-client-from-frontend-such-as-react/203676
**Category:** Elasticsearch
**Created:** [October 15, 2019, 2:50pm UTC](https://discuss.elastic.co/t/can-we-execute-the-search-template-without-using-client-from-frontend-such-as-react/203676 "2019-10-15T14:50:14Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![decodeit](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/decodeit/32/46023_2.png) [@decodeit](https://discuss.elastic.co/u/decodeit)
#### Post date: [October 15, 2019, 2:50pm UTC](https://discuss.elastic.co/t/can-we-execute-the-search-template-without-using-client-from-frontend-such-as-react/203676/1 "2019-10-15T14:50:14Z")

</div>

I have created a search template following docs like:  
`POST _scripts/<templateid> { "script": { "lang": "mustache", "source": { "query": { "match": { "title": "{{query_string}}" } } } } }`

but now i want to access this search template(use it) from my react application.  
Can I send a fetch to localhost:9200/\_search/template.  
Is this even possible from front end?

if yes how can it be done as a fetch call?

Thanks a lot.

---

<div class="post-metadata">

### Author: ![klof](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/klof/32/31590_2.png) [@klof](https://discuss.elastic.co/u/klof)
#### Post date: [October 16, 2019, 5:48am UTC](https://discuss.elastic.co/t/can-we-execute-the-search-template-without-using-client-from-frontend-such-as-react/203676/2 "2019-10-16T05:48:55Z")

</div>

Yes, it's doable :

```auto
GET _search/template
{
    "id": "<templateid>", 
    "params": {
        "query_string": "search for these words"
    }
}

```

[https://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html#use-registered-templates](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html#use-registered-templates)

---

<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: [November 13, 2019, 5:48am UTC](https://discuss.elastic.co/t/can-we-execute-the-search-template-without-using-client-from-frontend-such-as-react/203676/3 "2019-11-13T05:48:57Z")

</div>

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