We are trying to query from ElasticSearchDB the pseudo code is as shown below.
public String searchMovieRelease(){
String movieRelease=null;
WebTarget webTarget = target.path("_search/template"); (1)
Invocation.Builder builder = getInvokationBuilder(target); (2)
movieRelease = builder.post(Entity.json(query)); (3)
return movieRelease;
}
- Fetch the target which points to the required URI.
- Fetch the build
- Post the request the query through the builder and obtain the response from elastic search.
Now, how do, I achieve the same using RestHighLevelClient.
CodePudding user response:
You can do this way:
var client = new RestHighLevelClient(RestClient.builder(HttpHost.create("host"))
.setRequestConfigCallback(requestConfigBuilder -> requestConfigBuilder.setConnectTimeout(60000).setSocketTimeout(60000)));
var lowClient = client.getLowLevelClient();
var request = new Request("GET", "endpoint");
var response = lowClient.performRequest(request);