# Registering search templates with conditionals via REST API

**URL:** <https://discuss.elastic.co/t/registering-search-templates-with-conditionals-via-rest-api/20360>\
**Category:** Elasticsearch\
**Created:** [October 21, 2014, 10:41am UTC](https://discuss.elastic.co/t/registering-search-templates-with-conditionals-via-rest-api/20360 "2014-10-21T10:41:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dany\_Gielow](https://avatars.discourse-cdn.com/v4/letter/d/3bc359/32.png) [@Dany\_Gielow](https://discuss.elastic.co/u/Dany_Gielow)\
**Post date:** [October 21, 2014, 10:41am UTC](https://discuss.elastic.co/t/registering-search-templates-with-conditionals-via-rest-api/20360/1 "2014-10-21T10:41:32Z")

</div>

Hi,

How is it possible to pre-register a search template with conditionals via  
REST API in version 1.3.4?

When I try to use the example template from  
[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-template.html#\_conditional\_clauses](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-template.html#_conditional_clauses)  
I get a JsonParseException.

So the example template looks like:

POST /\_search/template/test  
{  
"template": {  
"query": {  
"filtered": {  
"query": {  
"match": {  
"line": "{{text}}"  
}  
},  
"filter": {  
{{#line\_no}}  
"range": {  
"line\_no": {  
{{#start}}  
"gte": "{{start}}"  
{{#end}},{{/end}}  
{{/start}}  
{{#end}}  
"lte": "{{end}}"  
{{/end}}  
}  
}  
{{/line\_no}}  
}  
}  
}  
}  
}

Do I have to use a mustache file for that?

Thanks in advance  
Dany

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/f047fc3b-3ee3-4b77-8836-847ce6613d8b%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/f047fc3b-3ee3-4b77-8836-847ce6613d8b%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:** [July 6, 2017, 12:54am UTC](https://discuss.elastic.co/t/registering-search-templates-with-conditionals-via-rest-api/20360/2 "2017-07-06T00:54:47Z")

</div>


