# Search Templates - sections not working?

**URL:** <https://discuss.elastic.co/t/search-templates-sections-not-working/20514>\
**Category:** Elasticsearch\
**Created:** [October 31, 2014, 12:58pm UTC](https://discuss.elastic.co/t/search-templates-sections-not-working/20514 "2014-10-31T12:58:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lukas\_Vlcek1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas_vlcek1/32/819_2.png) [@Lukas\_Vlcek1](https://discuss.elastic.co/u/Lukas_Vlcek1)\
**Post date:** [October 31, 2014, 12:58pm UTC](https://discuss.elastic.co/t/search-templates-sections-not-working/20514/1 "2014-10-31T12:58:43Z")

</div>

Hi,

I can not make Search Templates with Sections to work. Anybody has any idea  
what I do wrong?

Let's first take a simple example that works (#1) and then I expand it a  
bit (#2).

# Example 1 (works fine)

GET \_search/template  
{  
"template" : {  
"size": "{{size}}",  
"query": {  
"match\_all": {}  
}  
},  
"params": {  
"size": 2  
}  
}

# Example 2 (fails) - it is the same query as in #1 except it should make

the "size" optional depending on params input.

GET \_search/template  
{  
"template" : {  
{{#apply\_size}}  
"size": "{{size}}",  
{{/apply\_size}}  
"query": {  
"match\_all": {}  
}  
},  
"params": {  
"size": 2,  
"apply\_size": false  
}  
}

Yields:  
ElasticsearchParseException[Failed to parse template]; nested:  
JsonParseException[Unexpected character ('{' (code 123)): was expecting  
either valid name character (for unquoted name) or double-quote (for  
quoted) to start field name\n at [Source: [B@7384e1ef; line: 3, column: 6]]; }]","status":400

Tested with ES:

{"number" : "1.3.0", "build\_hash" :  
"1265b1454eee7725a6918f57415c480028700fb4", "build\_timestamp" :  
"2014-07-23T13:46:36Z", "build\_snapshot" : false, "lucene\_version" : "4.9"}

Regards,  
Lukas

--  
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/CAO9cvUYFzq-4HCy%3DUn%3DaY\_jQ%2BMreQHA939jeX5ynKhehm1Kiqw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAO9cvUYFzq-4HCy%3DUn%3DaY_jQ%2BMreQHA939jeX5ynKhehm1Kiqw%40mail.gmail.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:52am UTC](https://discuss.elastic.co/t/search-templates-sections-not-working/20514/2 "2017-07-06T00:52:50Z")

</div>

Closed on July 6, 2017, 12:52am UTC


