You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Current way of telling elastic client whether to use https or not is by calling usingSssl on the builder like this:
@Configuration
@RequiredArgsConstructor
@EnableElasticsearchRepositories
@Profile({"staging", "prod"})
public class ElasticsearchConfig extends ElasticsearchConfiguration {
private final ElasticsearchConfigProperties properties;
@NotNull
@Override
@Bean(name = {"elasticsearchClientConfiguration"})
public ClientConfiguration clientConfiguration() {
return ClientConfiguration.builder()
.connectedTo(properties.getHost() + ":" + properties.getPort())
.usingSsl()
.withBasicAuth(properties.getUsername(), properties.getPassword())
.build();
}
}
The problem with that is that in different profiles you may or may not need https. With this way of configuring it, you either need to create a separate config class for a profile where you don't need https, and omit .usingSsl() there, or do something like this:
@NotNull
@Override
@Bean(name = {"elasticsearchClientConfiguration"})
public ClientConfiguration clientConfiguration() {
var clientBuilder = ClientConfiguration.builder()
.connectedTo(properties.getHost() + ":" + properties.getPort())
.withBasicAuth(properties.getUsername(), properties.getPassword());
if (properties.useHttps()) {
clientBuilder.usingSsl()
}
return clientBuilder.build();
}
}
I suggest adding an overload of usingSsl that would accept a boolean, so you could do something like this:
Note that ElasticsearchConfigProperties is my configuration properties class. With this approach you could configure using ssl or not with .properties files.
The text was updated successfully, but these errors were encountered:
Hi,
Current way of telling elastic client whether to use https or not is by calling usingSssl on the builder like this:
The problem with that is that in different profiles you may or may not need https. With this way of configuring it, you either need to create a separate config class for a profile where you don't need https, and omit .usingSsl() there, or do something like this:
I suggest adding an overload of usingSsl that would accept a boolean, so you could do something like this:
Note that ElasticsearchConfigProperties is my configuration properties class. With this approach you could configure using ssl or not with .properties files.
The text was updated successfully, but these errors were encountered: