Justin Thomas
Justin Thomas

Reputation: 5848

How do you execute a search template query in elasticsearch?

$ curl -XGET localhost:9200/_search/template/products_template?pretty -d '
{"params": {"search_term": "my search"}}'

I have a template stored above. I can't get it to execute, putting _render in place of _search gets the rendered template, but I need results.

Calling the above results in:

{
  "lang" : "mustache",
  "_id" : "products_template",
  "found" : true,
  "template" : "{\"query\":{\"match\":{\"title\":\"{{ search_term }}\"}}}"
}

How do I get results? Do I have to make two calls?

Upvotes: 0

Views: 51

Answers (1)

fylie
fylie

Reputation: 1715

curl -XGET localhost:9200/_search/template -d 
'{ "id":"products_template", "params": {"search_term": "my_search"} }'

Upvotes: 1

Related Questions