Skip to content

Commit

Permalink
Migrate vector store auto-configurations to dedicated modules
Browse files Browse the repository at this point in the history
Move vector store auto-configuration classes to dedicated modules under auto-configurations/vector-stores/:

- Creates separate modules for Milvus, Pinecone, Qdrant, and Typesense vector stores
- Moves CommonVectorStoreProperties to spring-ai-core for better reusability
- Updates pom.xml dependencies to maintain proper relationships between modules

This change improves modularity by allowing each vector store implementation to be
independently versioned and maintained, continuing the migration pattern established
with previous vector stores.

Signed-off-by: Soby Chacko <soby.chacko@broadcom.com>
  • Loading branch information
sobychacko committed Feb 25, 2025
1 parent b29076f commit 95c2cd2
Show file tree
Hide file tree
Showing 47 changed files with 541 additions and 91 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2023-2025 the original author or authors.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ https://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../../../pom.xml</relativePath>
</parent>
<artifactId>spring-ai-milvus-store-spring-boot-autoconfigure</artifactId>
<packaging>jar</packaging>
<name>Spring AI Auto Configuration for Weaviate vector store</name>
<description>Spring AI Auto Configuration for Weaviate vector store</description>
<url>https://github.com/spring-projects/spring-ai</url>

<scm>
<url>https://github.com/spring-projects/spring-ai</url>
<connection>git://github.com/spring-projects/spring-ai.git</connection>
<developerConnection>git@github.com:spring-projects/spring-ai.git</developerConnection>
</scm>

<dependencies>
<!-- production dependencies -->
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-milvus-store</artifactId>
<version>${project.parent.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<!-- test dependencies -->
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-test</artifactId>
<version>${project.parent.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-testcontainers</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>milvus</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-transformers</artifactId>
<version>${project.parent.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package org.springframework.ai.autoconfigure.vectorstore.milvus;

import org.springframework.ai.autoconfigure.vectorstore.CommonVectorStoreProperties;
import org.springframework.ai.vectorstore.properties.CommonVectorStoreProperties;
import org.springframework.ai.vectorstore.milvus.MilvusVectorStore;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.util.Assert;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#
# Copyright 2025-2025 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
org.springframework.ai.autoconfigure.vectorstore.milvus.MilvusVectorStoreAutoConfiguration
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023-2024 the original author or authors.
* Copyright 2023-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -29,6 +29,7 @@
import org.springframework.ai.document.Document;
import org.springframework.ai.embedding.EmbeddingModel;
import org.springframework.ai.observation.conventions.VectorStoreProvider;
import org.springframework.ai.test.vectorstore.ObservationTestUtil;
import org.springframework.ai.transformers.TransformersEmbeddingModel;
import org.springframework.ai.vectorstore.SearchRequest;
import org.springframework.ai.vectorstore.VectorStore;
Expand All @@ -39,7 +40,6 @@
import org.springframework.context.annotation.Configuration;

import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.ai.autoconfigure.vectorstore.observation.ObservationTestUtil.assertObservationRegistry;

/**
* @author Christian Tzolov
Expand Down Expand Up @@ -79,7 +79,7 @@ public void addAndSearch() {

vectorStore.add(this.documents);

assertObservationRegistry(observationRegistry, VectorStoreProvider.MILVUS,
ObservationTestUtil.assertObservationRegistry(observationRegistry, VectorStoreProvider.MILVUS,
VectorStoreObservationContext.Operation.ADD);
observationRegistry.clear();

Expand All @@ -94,7 +94,7 @@ public void addAndSearch() {
assertThat(resultDoc.getMetadata()).hasSize(2);
assertThat(resultDoc.getMetadata()).containsKeys("spring", "distance");

assertObservationRegistry(observationRegistry, VectorStoreProvider.MILVUS,
ObservationTestUtil.assertObservationRegistry(observationRegistry, VectorStoreProvider.MILVUS,
VectorStoreObservationContext.Operation.QUERY);
observationRegistry.clear();

Expand All @@ -104,7 +104,7 @@ public void addAndSearch() {
results = vectorStore.similaritySearch(SearchRequest.builder().query("Spring").topK(1).build());
assertThat(results).hasSize(0);

assertObservationRegistry(observationRegistry, VectorStoreProvider.MILVUS,
ObservationTestUtil.assertObservationRegistry(observationRegistry, VectorStoreProvider.MILVUS,
VectorStoreObservationContext.Operation.DELETE);
observationRegistry.clear();

Expand All @@ -131,7 +131,7 @@ public void searchWithCustomFields() {

vectorStore.add(this.documents);

assertObservationRegistry(observationRegistry, VectorStoreProvider.MILVUS,
ObservationTestUtil.assertObservationRegistry(observationRegistry, VectorStoreProvider.MILVUS,
VectorStoreObservationContext.Operation.ADD);
observationRegistry.clear();

Expand All @@ -146,7 +146,7 @@ public void searchWithCustomFields() {
assertThat(resultDoc.getMetadata()).hasSize(2);
assertThat(resultDoc.getMetadata()).containsKeys("spring", "distance");

assertObservationRegistry(observationRegistry, VectorStoreProvider.MILVUS,
ObservationTestUtil.assertObservationRegistry(observationRegistry, VectorStoreProvider.MILVUS,
VectorStoreObservationContext.Operation.QUERY);
observationRegistry.clear();

Expand All @@ -156,7 +156,7 @@ public void searchWithCustomFields() {
results = vectorStore.similaritySearch(SearchRequest.builder().query("Spring").topK(1).build());
assertThat(results).hasSize(0);

assertObservationRegistry(observationRegistry, VectorStoreProvider.MILVUS,
ObservationTestUtil.assertObservationRegistry(observationRegistry, VectorStoreProvider.MILVUS,
VectorStoreObservationContext.Operation.DELETE);
observationRegistry.clear();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2023-2025 the original author or authors.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ https://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../../../pom.xml</relativePath>
</parent>
<artifactId>spring-ai-pinecone-store-spring-boot-autoconfigure</artifactId>
<packaging>jar</packaging>
<name>Spring AI Auto Configuration for Weaviate vector store</name>
<description>Spring AI Auto Configuration for Weaviate vector store</description>
<url>https://github.com/spring-projects/spring-ai</url>

<scm>
<url>https://github.com/spring-projects/spring-ai</url>
<connection>git://github.com/spring-projects/spring-ai.git</connection>
<developerConnection>git@github.com:spring-projects/spring-ai.git</developerConnection>
</scm>

<dependencies>
<!-- production dependencies -->
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-pinecone-store</artifactId>
<version>${project.parent.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<!-- test dependencies -->
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-test</artifactId>
<version>${project.parent.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-testcontainers</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-transformers</artifactId>
<version>${project.parent.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#
# Copyright 2025-2025 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
org.springframework.ai.autoconfigure.vectorstore.pinecone.PineconeVectorStoreAutoConfiguration
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023-2024 the original author or authors.
* Copyright 2023-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -32,6 +32,7 @@
import org.springframework.ai.document.Document;
import org.springframework.ai.embedding.EmbeddingModel;
import org.springframework.ai.observation.conventions.VectorStoreProvider;
import org.springframework.ai.test.vectorstore.ObservationTestUtil;
import org.springframework.ai.transformers.TransformersEmbeddingModel;
import org.springframework.ai.vectorstore.pinecone.PineconeVectorStore;
import org.springframework.ai.vectorstore.SearchRequest;
Expand Down Expand Up @@ -95,8 +96,8 @@ public void addAndSearchTest() {

vectorStore.add(this.documents);

org.springframework.ai.autoconfigure.vectorstore.observation.ObservationTestUtil.assertObservationRegistry(
observationRegistry, VectorStoreProvider.PINECONE, VectorStoreObservationContext.Operation.ADD);
ObservationTestUtil.assertObservationRegistry(observationRegistry, VectorStoreProvider.PINECONE,
VectorStoreObservationContext.Operation.ADD);

Awaitility.await()
.until(() -> vectorStore.similaritySearch(SearchRequest.builder().query("Spring").topK(1).build()),
Expand All @@ -114,15 +115,15 @@ public void addAndSearchTest() {
assertThat(resultDoc.getMetadata()).hasSize(2);
assertThat(resultDoc.getMetadata()).containsKeys("spring", "customDistanceField");

org.springframework.ai.autoconfigure.vectorstore.observation.ObservationTestUtil.assertObservationRegistry(
observationRegistry, VectorStoreProvider.PINECONE, VectorStoreObservationContext.Operation.QUERY);
ObservationTestUtil.assertObservationRegistry(observationRegistry, VectorStoreProvider.PINECONE,
VectorStoreObservationContext.Operation.QUERY);
observationRegistry.clear();

// Remove all documents from the store
vectorStore.delete(this.documents.stream().map(doc -> doc.getId()).toList());

org.springframework.ai.autoconfigure.vectorstore.observation.ObservationTestUtil.assertObservationRegistry(
observationRegistry, VectorStoreProvider.PINECONE, VectorStoreObservationContext.Operation.DELETE);
ObservationTestUtil.assertObservationRegistry(observationRegistry, VectorStoreProvider.PINECONE,
VectorStoreObservationContext.Operation.DELETE);
observationRegistry.clear();

Awaitility.await()
Expand Down
Loading

0 comments on commit 95c2cd2

Please # to comment.