# Template queries and mustache used for collections

**URL:** <https://discuss.elastic.co/t/template-queries-and-mustache-used-for-collections/21710>\
**Category:** Elasticsearch\
**Created:** [January 19, 2015, 1:21pm UTC](https://discuss.elastic.co/t/template-queries-and-mustache-used-for-collections/21710 "2015-01-19T13:21:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rafael\_Kubina](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rafael_kubina/32/83691_2.png) [@Rafael\_Kubina](https://discuss.elastic.co/u/Rafael_Kubina)\
**Post date:** [January 19, 2015, 1:21pm UTC](https://discuss.elastic.co/t/template-queries-and-mustache-used-for-collections/21710/1 "2015-01-19T13:21:56Z")

</div>

Hello @all,

I´m struggling with mustache and collections together with template queries:

my objects/docs:  
{  
"id":1  
"knows":[2,3,4,5]  
}  
.. and so on

desired query to be rendered:  
...  
"query" : {  
"should": [  
{  
"term": {"knows": 2 }  
},  
{  
"term": {"knows": 3 }  
},  
]  
}  
...

current mustache template (w/o errors while storing):  
{  
"template" : {  
"query" : {  
"filtered" : {  
"filter" : {  
"query" : {  
"should": [  
"{{#know}}{{ { "term": { "knows": {{know}} } }  
}}{{/know}}"  
]  
}  
}  
}  
}  
}  
}

passed params (throws Parse Failure [Failed to parse source  
[{"query":{"filtered":{"filter":{"query":{"should":[" } } }} } }  
}}"]}}}}}]]] ):  
{  
"params" : {  
"know" : [2,3]  
}  
}

Is anyone able to help me out?

--  
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/a2dd823a-6270-48e3-b019-78dee5f71e49%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a2dd823a-6270-48e3-b019-78dee5f71e49%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:38am UTC](https://discuss.elastic.co/t/template-queries-and-mustache-used-for-collections/21710/2 "2017-07-06T00:38:01Z")

</div>


