How to use JSON query with RestHighLevelClient API


(Mai Sannohe) #1

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


(Kevybear) #2

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


(Mai Sannohe) #3

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


(system) #4

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