How to use JSON query with RestHighLevelClient API

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

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

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

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

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