diff --git a/charts/ccd-definition-store-api/values.preview.template.yaml b/charts/ccd-definition-store-api/values.preview.template.yaml index fe3ff662f1..ad08e0dc06 100644 --- a/charts/ccd-definition-store-api/values.preview.template.yaml +++ b/charts/ccd-definition-store-api/values.preview.template.yaml @@ -24,7 +24,9 @@ java: # enable whenever required and provide host url to match with corresponding data-store-api ELASTIC_SEARCH_ENABLED: true - ELASTIC_SEARCH_HOST: ccd-data-store-api-pr-1260-es-master + ELASTIC_SEARCH_HOST: elastic-poc-ccd.es.privatelink.uksouth.azure.elastic-cloud.com + ELASTIC_SEARCH_PORT: 443 + ELASTIC_SEARCH_SCHEME: https USER_PROFILE_HOST: http://ccd-user-profile-api-pr-399-java diff --git a/elastic-search-support/src/main/java/uk/gov/hmcts/ccd/definition/store/elastic/config/ElasticSearchConfiguration.java b/elastic-search-support/src/main/java/uk/gov/hmcts/ccd/definition/store/elastic/config/ElasticSearchConfiguration.java index 0196f5013f..7a53eccb7f 100644 --- a/elastic-search-support/src/main/java/uk/gov/hmcts/ccd/definition/store/elastic/config/ElasticSearchConfiguration.java +++ b/elastic-search-support/src/main/java/uk/gov/hmcts/ccd/definition/store/elastic/config/ElasticSearchConfiguration.java @@ -5,6 +5,7 @@ import org.elasticsearch.client.RestClient; import org.elasticsearch.client.RestClientBuilder; import org.elasticsearch.client.RestHighLevelClient; +import org.elasticsearch.client.RestHighLevelClientBuilder; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.boot.context.properties.EnableConfigurationProperties; @@ -34,12 +35,20 @@ public class ElasticSearchConfiguration { @Bean @Scope(BeanDefinition.SCOPE_PROTOTYPE) public RestHighLevelClient restHighLevelClient() { - RestClientBuilder builder = RestClient.builder(new HttpHost(config.getHost(), config.getPort())); + RestClientBuilder builder = RestClient.builder(new HttpHost( + config.getHost(), config.getPort(), config.getScheme())); RestClientBuilder.RequestConfigCallback requestConfigCallback = requestConfigBuilder -> requestConfigBuilder.setConnectTimeout(5000) .setSocketTimeout(60000); builder.setRequestConfigCallback(requestConfigCallback); - return new RestHighLevelClient(builder); + RestClient restClient = builder.build(); + // Create the HLRC + RestHighLevelClient hlrc = new RestHighLevelClientBuilder(restClient) + .setApiCompatibilityMode(true) + .build(); + // hlrc and esClient share the same httpClient + + return hlrc; } @Bean diff --git a/elastic-search-support/src/test/resources/application-default.yml b/elastic-search-support/src/test/resources/application-default.yml index d0125dd776..c736bd85ad 100644 --- a/elastic-search-support/src/test/resources/application-default.yml +++ b/elastic-search-support/src/test/resources/application-default.yml @@ -1,9 +1,9 @@ elasticsearch: - host: localhost - port: 9200 - scheme: http + host: ${ELASTIC_SEARCH_HOST:localhost} + port: ${ELASTIC_SEARCH_PORT:9200} + scheme: ${ELASTIC_SEARCH_SCHEME:http} enabled: true indexShards: 8 indexShardsReplicas: 3 failImportIfError: true - dynamic: true + dynamic: true \ No newline at end of file