# Java-API: search template: passing an array as parameter

**URL:** <https://discuss.elastic.co/t/java-api-search-template-passing-an-array-as-parameter/21031>\
**Category:** Elasticsearch\
**Created:** [December 2, 2014, 12:20pm UTC](https://discuss.elastic.co/t/java-api-search-template-passing-an-array-as-parameter/21031 "2014-12-02T12:20:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![janne\_olesen](https://avatars.discourse-cdn.com/v4/letter/j/e19b73/32.png) [@janne\_olesen](https://discuss.elastic.co/u/janne_olesen)\
**Post date:** [December 2, 2014, 12:20pm UTC](https://discuss.elastic.co/t/java-api-search-template-passing-an-array-as-parameter/21031/1 "2014-12-02T12:20:52Z")

</div>

Hi,

I'm trying to use the java-api to pass an array of parameters to a search  
template. Since the SearchRequestBuilder.setTemplateParams only allows am Map\<String,  
String\> as parameter I'm stuck. Any ideas are wellcomed. I'm using  
Elasticsearch 1.4.0

Search Template created via sense:  
GET /\_search/template/test  
{  
"template": {  
"query": {  
"terms": {  
"searchterm": [  
"{{#searchterm}}",  
"{{.}}",  
"{{/searchterm}}"  
]  
}  
}  
}  
}

Calling the search template via REST works fine:  
GET /myindex/\_search/template  
{  
"template": {  
"id" : "test"  
},  
"params" : {  
"searchterm" : [  
"term1",  
"term2"  
]  
}  
}

--  
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/27cafc64-d21b-4fec-8273-3f92ef92ad8f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/27cafc64-d21b-4fec-8273-3f92ef92ad8f%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [December 2, 2014, 1:08pm UTC](https://discuss.elastic.co/t/java-api-search-template-passing-an-array-as-parameter/21031/2 "2014-12-02T13:08:10Z")

</div>

This has been fixed in elasticsearch 1.5 (branch 1.x): [Make template params take arrays by reuben-sutton · Pull Request #8255 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/pull/8255) [https://github.com/elasticsearch/elasticsearch/pull/8255](https://github.com/elasticsearch/elasticsearch/pull/8255)

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet [https://twitter.com/dadoonet](https://twitter.com/dadoonet) | @elasticsearchfr [https://twitter.com/elasticsearchfr](https://twitter.com/elasticsearchfr) | @scrutmydocs [https://twitter.com/scrutmydocs](https://twitter.com/scrutmydocs)

> Le 2 déc. 2014 à 13:20, [janne.olesen@oberbaum-concept.com](mailto:janne.olesen@oberbaum-concept.com) a écrit :
> 
> Hi,
> 
> I'm trying to use the java-api to pass an array of parameters to a search template. Since the SearchRequestBuilder.setTemplateParams only allows am Map\<String, String\> as parameter I'm stuck. Any ideas are wellcomed. I'm using Elasticsearch 1.4.0
> 
> Search Template created via sense:  
> GET /\_search/template/test  
> {  
> "template": {  
> "query": {  
> "terms": {  
> "searchterm": [  
> "{{#searchterm}}",  
> "{{.}}",  
> "{{/searchterm}}"  
> ]  
> }  
> }  
> }  
> }
> 
> Calling the search template via REST works fine:  
> GET /myindex/\_search/template  
> {  
> "template": {  
> "id" : "test"  
> },  
> "params" : {  
> "searchterm" : [  
> "term1",  
> "term2"  
> ]  
> }  
> }
> 
> --  
> 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) [mailto:elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/27cafc64-d21b-4fec-8273-3f92ef92ad8f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/27cafc64-d21b-4fec-8273-3f92ef92ad8f%40googlegroups.com) [https://groups.google.com/d/msgid/elasticsearch/27cafc64-d21b-4fec-8273-3f92ef92ad8f%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/27cafc64-d21b-4fec-8273-3f92ef92ad8f%40googlegroups.com?utm_medium=email&utm_source=footer).  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout) [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/354A25B5-81E9-4784-8BE8-4A0113421D25%40pilato.fr](https://groups.google.com/d/msgid/elasticsearch/354A25B5-81E9-4784-8BE8-4A0113421D25%40pilato.fr).  
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:46am UTC](https://discuss.elastic.co/t/java-api-search-template-passing-an-array-as-parameter/21031/3 "2017-07-06T00:46:36Z")

</div>


