2022-02-04 15:52:49 +01:00
|
|
|
package eu.dnetlib.scholix.api;
|
|
|
|
|
2022-02-08 09:57:45 +01:00
|
|
|
import eu.dnetlib.scholix.api.index.ElasticSearchPool;
|
2022-02-07 16:36:26 +01:00
|
|
|
import eu.dnetlib.scholix.api.index.ElasticSearchProperties;
|
2022-02-04 15:52:49 +01:00
|
|
|
import org.elasticsearch.client.RestHighLevelClient;
|
2022-02-07 16:36:26 +01:00
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
2022-02-04 15:52:49 +01:00
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
import org.springframework.data.elasticsearch.client.ClientConfiguration;
|
|
|
|
import org.springframework.data.elasticsearch.client.RestClients;
|
|
|
|
import org.springframework.data.elasticsearch.config.AbstractElasticsearchConfiguration;
|
|
|
|
|
|
|
|
import java.time.Duration;
|
|
|
|
|
|
|
|
@Configuration
|
2022-02-08 09:57:45 +01:00
|
|
|
public class RestClientConfig {
|
2022-02-04 15:52:49 +01:00
|
|
|
|
2022-02-07 16:36:26 +01:00
|
|
|
@Autowired
|
|
|
|
private ElasticSearchProperties elasticSearchProperties;
|
|
|
|
|
2022-02-08 09:57:45 +01:00
|
|
|
|
2022-02-04 15:52:49 +01:00
|
|
|
@Bean
|
2022-02-08 09:57:45 +01:00
|
|
|
public ElasticSearchPool connectionPool() {
|
|
|
|
|
|
|
|
ElasticSearchPool pool = new ElasticSearchPool(elasticSearchProperties);
|
|
|
|
return pool;
|
2022-02-04 15:52:49 +01:00
|
|
|
}
|
2022-02-08 09:57:45 +01:00
|
|
|
|
|
|
|
|
|
|
|
// @Override
|
|
|
|
// @Bean
|
|
|
|
// public RestHighLevelClient elasticsearchClient() {
|
|
|
|
//
|
|
|
|
// final ClientConfiguration clientConfiguration = ClientConfiguration.builder()
|
|
|
|
// .connectedTo(elasticSearchProperties.getClusterNodes().split(","))
|
|
|
|
// .withConnectTimeout(elasticSearchProperties.getConnectionTimeout())
|
|
|
|
// .withSocketTimeout(elasticSearchProperties.getSocketTimeout())
|
|
|
|
// .build();
|
|
|
|
// return RestClients.create(clientConfiguration).rest();
|
|
|
|
// }
|
2022-02-04 15:52:49 +01:00
|
|
|
}
|