Fix a merge bug in OpenSearchConfiguration#openSearchClient
Resolves #923
This commit is contained in:
@@ -71,12 +71,15 @@ public class OpenSearchVectorStoreAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
OpenSearchClient openSearchClient(OpenSearchVectorStoreProperties properties) {
|
||||
HttpHost[] httpHosts = properties.getUris().stream().map(s -> createHttpHost(s)).toArray(HttpHost[]::new);
|
||||
OpenSearchClient openSearchClient(OpenSearchConnectionDetails connectionDetails) {
|
||||
HttpHost[] httpHosts = connectionDetails.getUris()
|
||||
.stream()
|
||||
.map(s -> createHttpHost(s))
|
||||
.toArray(HttpHost[]::new);
|
||||
ApacheHttpClient5TransportBuilder transportBuilder = ApacheHttpClient5TransportBuilder.builder(httpHosts);
|
||||
|
||||
Optional.ofNullable(properties.getUsername())
|
||||
.map(username -> createBasicCredentialsProvider(httpHosts[0], username, properties.getPassword()))
|
||||
Optional.ofNullable(connectionDetails.getUsername())
|
||||
.map(username -> createBasicCredentialsProvider(httpHosts[0], username,
|
||||
connectionDetails.getPassword()))
|
||||
.ifPresent(basicCredentialsProvider -> transportBuilder
|
||||
.setHttpClientConfigCallback(httpAsyncClientBuilder -> httpAsyncClientBuilder
|
||||
.setDefaultCredentialsProvider(basicCredentialsProvider)));
|
||||
|
||||
@@ -27,7 +27,7 @@ public class OpenSearchVectorStoreProperties {
|
||||
/**
|
||||
* Comma-separated list of the OpenSearch instances to use.
|
||||
*/
|
||||
private List<String> uris;
|
||||
private List<String> uris = List.of();
|
||||
|
||||
private String indexName;
|
||||
|
||||
|
||||
@@ -57,10 +57,6 @@ class MilvusContainerConnectionDetailsFactoryTest {
|
||||
new Document(ResourceUtils.getText("classpath:/test/data/time.shelter.txt")), new Document(
|
||||
ResourceUtils.getText("classpath:/test/data/great.depression.txt"), Map.of("depression", "bad")));
|
||||
|
||||
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(MilvusVectorStoreAutoConfiguration.class))
|
||||
.withUserConfiguration(Config.class);
|
||||
|
||||
@Autowired
|
||||
private VectorStore vectorStore;
|
||||
|
||||
|
||||
@@ -15,6 +15,14 @@
|
||||
*/
|
||||
package org.springframework.ai.testcontainers.service.connection.opensearch;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.hamcrest.Matchers.hasSize;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.awaitility.Awaitility;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.opensearch.testcontainers.OpensearchContainer;
|
||||
@@ -34,14 +42,6 @@ import org.springframework.core.io.DefaultResourceLoader;
|
||||
import org.testcontainers.junit.jupiter.Container;
|
||||
import org.testcontainers.junit.jupiter.Testcontainers;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.hamcrest.Matchers.hasSize;
|
||||
|
||||
@SpringBootTest(properties = {
|
||||
"spring.ai.vectorstore.opensearch.index-name=" + OpenSearchContainerConnectionDetailsFactoryTest.DOCUMENT_INDEX,
|
||||
"spring.ai.vectorstore.opensearch.mapping-json="
|
||||
|
||||
Reference in New Issue
Block a user