# Pass array to search template

**URL:** <https://discuss.elastic.co/t/pass-array-to-search-template/222644>\
**Category:** Elasticsearch\
**Created:** [March 9, 2020, 5:50am UTC](https://discuss.elastic.co/t/pass-array-to-search-template/222644 "2020-03-09T05:50:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![JdKock](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jdkock/32/26327_2.png) [@JdKock](https://discuss.elastic.co/u/JdKock)\
**Post date:** [March 9, 2020, 5:50am UTC](https://discuss.elastic.co/t/pass-array-to-search-template/222644/1 "2020-03-09T05:50:31Z")

</div>

I have a search template and now I need to pass some parameters. Strings are no problem, but how do I pass an array?

In the documentation I found that I need to use {{#toJson}}. But this seems not to work.  
[https://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html#search-template-converting-to-json](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html#search-template-converting-to-json)

Search template:  
"filter": [  
{  
"terms": "{{#toJson}}types{{/toJson}}"  
},

Parameter:  
"types": {  
"type": ["type1","type2","type3"]  
}

Anybody has a solution for passing an array to the search template ?

---

<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:** [April 6, 2020, 5:50am UTC](https://discuss.elastic.co/t/pass-array-to-search-template/222644/2 "2020-04-06T05:50:36Z")

</div>

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