HttpHost regression issues in OpenSearchVectorStoreAutoConfiguration

Changes introduced for https://github.com/spring-projects/spring-ai/issues/2954
introduced a regression in the way OpenSearch works with test containers.

Restore the retrieval of HttpHost from OpenSearchConnectionDetails insted of getting
them directly from properties.

Signed-off-by: Soby Chacko <soby.chacko@broadcom.com>
This commit is contained in:
Soby Chacko
2025-05-13 08:47:47 -04:00
committed by Mark Pollack
parent 54e5c07428
commit f346092648

View File

@@ -105,8 +105,14 @@ public class OpenSearchVectorStoreAutoConfiguration {
@Bean
@ConditionalOnMissingBean
OpenSearchClient openSearchClient(OpenSearchVectorStoreProperties properties, Optional<SslBundles> sslBundles) {
HttpHost[] httpHosts = properties.getUris().stream().map(this::createHttpHost).toArray(HttpHost[]::new);
OpenSearchClient openSearchClient(OpenSearchVectorStoreProperties properties,
OpenSearchConnectionDetails connectionDetails, Optional<SslBundles> sslBundles) {
HttpHost[] httpHosts = connectionDetails.getUris()
.stream()
.map(s -> createHttpHost(s))
.toArray(HttpHost[]::new);
Optional<BasicCredentialsProvider> basicCredentialsProvider = Optional.ofNullable(properties.getUsername())
.map(username -> createBasicCredentialsProvider(httpHosts, username, properties.getPassword()));