Since moving to 6.6.1 REST client, I noticed my client connection is not closing.
So I am using a System.exit(0) at the method end.
FYI: The document is getting stored and update din Elastic!
This is how I get my client/authenticate:
String CREDENTIALS_STRING = this.username+":"+this.password;
String encodedBytes = Base64.getEncoder().encodeToString(CREDENTIALS_STRING.getBytes());
Header[] headers = { new BasicHeader(HttpHeaders.CONTENT_TYPE, "application/json"),
new BasicHeader("Authorization", "Basic " + encodedBytes) };
this.client = new RestHighLevelClient(RestClient.builder(
new HttpHost(this.END_POINT, 9243, "https")).setDefaultHeaders(headers));
return this.client;
This is how I used to do it:
String CREDENTIALS_STRING = this.username+":"+this.password;
String encodedBytes = Base64.getEncoder().encodeToString(CREDENTIALS_STRING.getBytes());
Header[] headers = { new BasicHeader(HttpHeaders.CONTENT_TYPE, "application/json"),
new BasicHeader("Authorization", "Basic " + encodedBytes) };
this.restLowLevelClient = RestClient.builder(
new HttpHost(this.END_POINT, 9243, "https")).setDefaultHeaders(headers).build();
this.client = new RestHighLevelClient(restLowLevelClient);
return this.client;
At the end of the request, I am attempting to evaluate the response. I am getting "NOOP" when I check the UpdateResponse, what does that mean?:
IndexRequest indexRequest = new IndexRequest(indexName, docType,
String.valueOf(fieldMap.get(updateIdField))).source(fieldMap);
UpdateRequest upR = new UpdateRequest(indexName, docType, String.valueOf(fieldMap.get(updateIdField)))
.doc(indexRequest).upsert(indexRequest);
UpdateResponse updateResponse = null;
try {
updateResponse = client.update(upR, RequestOptions.DEFAULT);
System.out.println(updateResponse.getResult());
//here it's printing "NOOP"
} catch (IOException ioe) {
ioe.printStackTrace();
}
Also, when I send the request, I use RequestOptions.DEFAULT. does this interfere with my Headers that I set initially when getting the client? I feel like I may be undoing the client when I follow up using DEFAULT RequestOptions?? :
updateResponse = client.update(upR, RequestOptions.DEFAULT);