fabriziofortino commented on code in PR #490:
URL: https://github.com/apache/jackrabbit-oak/pull/490#discussion_r872080573
##########
oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticConnection.java:
##########
@@ -108,11 +123,41 @@ public RestHighLevelClient getClient() {
Header[] headers = new Header[]{new
BasicHeader("Authorization", "ApiKey " + apiKeyAuth)};
builder.setDefaultHeaders(headers);
}
- client = new RestHighLevelClient(builder);
+ RestClient httpClient = builder.build();
+ hlClient = new
RestHighLevelClientBuilder(httpClient).setApiCompatibilityMode(true).build();
+
+ ElasticsearchTransport transport = new RestClientTransport(
+ httpClient, new JacksonJsonpMapper());
+ esClient = new ElasticsearchClient(transport);
+ esAsyncClient = new ElasticsearchAsyncClient(transport);
}
}
}
- return client;
+ return Tuple.tuple(Tuple.tuple(esClient, esAsyncClient), hlClient);
+ }
+
+ /**
+ * Gets the Elasticsearch Client
+ * @return the Elasticsearch client
+ */
+ public ElasticsearchClient getClient() {
+ return getClients().v1().v1();
Review Comment:
Makes sense. I have created an internal class (`Clients`) to wrap up all the
clients. I preferred it to a Map since it's strongly typed (no need to cast).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]