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

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.

Yes, it's doable :

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

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