# How to use JSON query with RestHighLevelClient API

**URL:** <https://discuss.elastic.co/t/how-to-use-json-query-with-resthighlevelclient-api/133267>\
**Category:** Elasticsearch\
**Created:** [May 25, 2018, 6:56am UTC](https://discuss.elastic.co/t/how-to-use-json-query-with-resthighlevelclient-api/133267 "2018-05-25T06:56:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mai\_3n](https://avatars.discourse-cdn.com/v4/letter/m/9de053/32.png) [@Mai\_3n](https://discuss.elastic.co/u/Mai_3n)\
**Post date:** [May 25, 2018, 6:56am UTC](https://discuss.elastic.co/t/how-to-use-json-query-with-resthighlevelclient-api/133267/1 "2018-05-25T06:56:01Z")

</div>

Hi,  
Now I'm using "org.elasticsearch.client:elasticsearch-rest-high-level-client:6.2.4" in my java application.  
I know that TransportClient will be deprecated in 7.0, so I'm trying to use RestHighLevelClient instead.

But now I can't find how to use Search Template with RestHighLevelClient API.

At least, the code in this url didn't work with RestHighLevelClient.  
[https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/java-search-template.html](https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/java-search-template.html)

I just want to load JSON string and use it as query.  
Can I use Search Template function? Or is there any other way to do that?

Can anyone help me?  
Mai

---

<div class="post-metadata">

**Author:** ![kevybear](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kevybear/32/25872_2.png) [@kevybear](https://discuss.elastic.co/u/kevybear)\
**Post date:** [May 28, 2018, 4:08am UTC](https://discuss.elastic.co/t/how-to-use-json-query-with-resthighlevelclient-api/133267/2 "2018-05-28T04:08:00Z")

</div>

I think you might have to use the low level rest client for this.

You can try RestHighLevelClient.getLowLevelClient() and use .performRequest()

Check this:  
[https://www.elastic.co/guide/en/elasticsearch/client/java-rest/6.2/java-rest-low-usage-requests.html](https://www.elastic.co/guide/en/elasticsearch/client/java-rest/6.2/java-rest-low-usage-requests.html)

---

<div class="post-metadata">

**Author:** ![Mai\_3n](https://avatars.discourse-cdn.com/v4/letter/m/9de053/32.png) [@Mai\_3n](https://discuss.elastic.co/u/Mai_3n)\
**Post date:** [May 28, 2018, 5:09am UTC](https://discuss.elastic.co/t/how-to-use-json-query-with-resthighlevelclient-api/133267/3 "2018-05-28T05:09:01Z")

</div>

Thank you so much!  
Now I got the result that I wanted.

---

<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:** [June 25, 2018, 5:09am UTC](https://discuss.elastic.co/t/how-to-use-json-query-with-resthighlevelclient-api/133267/4 "2018-06-25T05:09:02Z")

</div>

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