How to use JSON query with RestHighLevelClient API

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.

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?

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

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

Check this:

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.