Skip to content
Snippets Groups Projects
Commit 4c39cfaa authored by Homada.Boumedane's avatar Homada.Boumedane Committed by Mathieu.Vonlanthen
Browse files

refactor(Elastic Rest Client) add compatibility mode with ES8

parent 32dc7649
No related branches found
No related tags found
1 merge request!355refactor: refactor elastic rest client to add compatibilty with es8
......@@ -31,6 +31,7 @@ import org.apache.http.impl.client.BasicCredentialsProvider;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.RestHighLevelClientBuilder;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Service;
......@@ -59,12 +60,14 @@ public class ElasticsearchClientProvider {
if (indexProperties.getConfig().isSslEnabled()) {
scheme = "https";
}
HttpHost host = new HttpHost(indexProperties.getConfig().getHost(), indexProperties.getConfig().getPort(), scheme);
RestClientBuilder restClientBuilder = RestClient.builder(host);
restClientBuilder.setHttpClientConfigCallback(httpClientBuilder -> httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider));
this.elasticsearchClient = new RestHighLevelClient(restClientBuilder);
this.elasticsearchClient = new RestHighLevelClientBuilder(restClientBuilder.build())
.setApiCompatibilityMode(true)
.build();
}
public RestHighLevelClient getElasticsearchClient() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment