REST client initialization

As we've said, the high-level REST client is built on the top of the low-level REST client, so the constructor takes the RestClientBuilder object as an argument to build the high-level REST client object. Our example is shown in the following code block and is similar to the low-level REST client:

 public RestHighLevelClient HighLevelRestClient() {
return new RestHighLevelClient(
RestClient.builder(new HttpHost("localhost", 9200, "http"))
.setDefaultHeaders(new Header[] {
new BasicHeader("accept","application/json"),
new BasicHeader("content-type","application/json")})
.setFailureListener(new RestClient.FailureListener() {
public void onFailure(Node node) {
logger.error("High level Rest Client Failure on node " + node.getName());
}
}));
}
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.239.1