Remove vector store related deprecations introduced in 1.0.0-M5

This commit is contained in:
Soby Chacko
2025-01-06 17:55:03 -05:00
committed by Ilayaperumal Gopinathan
parent 3c539a37a3
commit eff7a80b07
24 changed files with 27 additions and 3428 deletions

View File

@@ -24,7 +24,6 @@ import org.springframework.ai.embedding.BatchingStrategy;
import org.springframework.ai.embedding.EmbeddingModel;
import org.springframework.ai.embedding.TokenCountBatchingStrategy;
import org.springframework.ai.vectorstore.cosmosdb.CosmosDBVectorStore;
import org.springframework.ai.vectorstore.cosmosdb.CosmosDBVectorStoreConfig;
import org.springframework.ai.vectorstore.observation.VectorStoreObservationConvention;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.AutoConfiguration;
@@ -32,6 +31,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import java.util.List;
/**
* {@link AutoConfiguration Auto-configuration} for CosmosDB Vector Store.
@@ -71,14 +71,14 @@ public class CosmosDBVectorStoreAutoConfiguration {
CosmosDBVectorStoreProperties properties, CosmosAsyncClient cosmosAsyncClient,
EmbeddingModel embeddingModel, BatchingStrategy batchingStrategy) {
CosmosDBVectorStoreConfig config = new CosmosDBVectorStoreConfig();
config.setDatabaseName(properties.getDatabaseName());
config.setContainerName(properties.getContainerName());
config.setMetadataFields(properties.getMetadataFields());
config.setVectorStoreThroughput(properties.getVectorStoreThroughput());
config.setVectorDimensions(properties.getVectorDimensions());
return new CosmosDBVectorStore(observationRegistry, customObservationConvention.getIfAvailable(),
cosmosAsyncClient, config, embeddingModel, batchingStrategy);
return CosmosDBVectorStore.builder(cosmosAsyncClient, embeddingModel)
.databaseName(properties.getDatabaseName())
.containerName(properties.getContainerName())
.metadataFields(List.of(properties.getMetadataFields()))
.vectorStoreThroughput(properties.getVectorStoreThroughput())
.vectorDimensions(properties.getVectorDimensions())
.build();
}
}

View File

@@ -22,7 +22,6 @@ import org.springframework.ai.embedding.BatchingStrategy;
import org.springframework.ai.embedding.EmbeddingModel;
import org.springframework.ai.embedding.TokenCountBatchingStrategy;
import org.springframework.ai.vectorstore.pinecone.PineconeVectorStore;
import org.springframework.ai.vectorstore.pinecone.PineconeVectorStore.PineconeVectorStoreConfig;
import org.springframework.ai.vectorstore.observation.VectorStoreObservationConvention;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.AutoConfiguration;

View File

@@ -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.
@@ -29,7 +29,6 @@ import org.springframework.ai.embedding.BatchingStrategy;
import org.springframework.ai.embedding.EmbeddingModel;
import org.springframework.ai.embedding.TokenCountBatchingStrategy;
import org.springframework.ai.vectorstore.typesense.TypesenseVectorStore;
import org.springframework.ai.vectorstore.typesense.TypesenseVectorStore.TypesenseVectorStoreConfig;
import org.springframework.ai.vectorstore.observation.VectorStoreObservationConvention;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.AutoConfiguration;

View File

@@ -19,7 +19,6 @@ package org.springframework.ai.autoconfigure.vectorstore.cassandra;
import org.junit.jupiter.api.Test;
import org.springframework.ai.vectorstore.cassandra.CassandraVectorStore;
import org.springframework.ai.vectorstore.cassandra.CassandraVectorStoreConfig;
import static org.assertj.core.api.Assertions.assertThat;

View File

@@ -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.
@@ -102,50 +102,6 @@ public class CosmosDBVectorStore extends AbstractObservationVectorStore implemen
private CosmosAsyncContainer container;
/**
* Creates a new CosmosDBVectorStore with basic configuration.
* @param observationRegistry the observation registry
* @param customObservationConvention the custom observation convention
* @param cosmosClient the Cosmos DB client
* @param properties the configuration properties
* @param embeddingModel the embedding model
* @deprecated Since 1.0.0-M5, use {@link #builder(CosmosAsyncClient, EmbeddingModel)}
* ()} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public CosmosDBVectorStore(ObservationRegistry observationRegistry,
VectorStoreObservationConvention customObservationConvention, CosmosAsyncClient cosmosClient,
CosmosDBVectorStoreConfig properties, EmbeddingModel embeddingModel) {
this(observationRegistry, customObservationConvention, cosmosClient, properties, embeddingModel,
new TokenCountBatchingStrategy());
}
/**
* Creates a new CosmosDBVectorStore with full configuration.
* @param observationRegistry the observation registry
* @param customObservationConvention the custom observation convention
* @param cosmosClient the Cosmos DB client
* @param properties the configuration properties
* @param embeddingModel the embedding model
* @param batchingStrategy the batching strategy
* @deprecated Since 1.0.0-M5, use {@link #builder(CosmosAsyncClient, EmbeddingModel)}
* ()} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public CosmosDBVectorStore(ObservationRegistry observationRegistry,
VectorStoreObservationConvention customObservationConvention, CosmosAsyncClient cosmosClient,
CosmosDBVectorStoreConfig properties, EmbeddingModel embeddingModel, BatchingStrategy batchingStrategy) {
this(builder(cosmosClient, embeddingModel).containerName(properties.getContainerName())
.databaseName(properties.getDatabaseName())
.partitionKeyPath(properties.getPartitionKeyPath())
.vectorStoreThroughput(properties.getVectorStoreThroughput())
.vectorDimensions(properties.getVectorDimensions())
.metadataFields(properties.getMetadataFieldsList())
.observationRegistry(observationRegistry)
.customObservationConvention(customObservationConvention)
.batchingStrategy(batchingStrategy));
}
/**
* Protected constructor that accepts a builder instance. This is the preferred way to
* create new CosmosDBVectorStore instances.

View File

@@ -1,213 +0,0 @@
/*
* Copyright 2023-2024 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.
*/
package org.springframework.ai.vectorstore.cosmosdb;
import java.util.List;
import com.azure.cosmos.CosmosAsyncClient;
import org.springframework.ai.embedding.EmbeddingModel;
/**
* Configuration properties for a CosmosDB vector store.
*
* @author Theo van Kraay
* @since 1.0.0
* @deprecated Since 1.0.0-M5, use
* {@link CosmosDBVectorStore#builder(CosmosAsyncClient, EmbeddingModel)} instead.
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public class CosmosDBVectorStoreConfig implements AutoCloseable {
private String containerName;
private String databaseName;
private String partitionKeyPath;
private String endpoint;
private String key;
private String metadataFields;
private int vectorStoreThroughput = 400;
private long vectorDimensions = 1536;
private List<String> metadataFieldsList;
/**
* @deprecated Since 1.0.0-M5, use
* {@link CosmosDBVectorStore#builder(CosmosAsyncClient, EmbeddingModel)} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public int getVectorStoreThroughput() {
return this.vectorStoreThroughput;
}
/**
* @deprecated Since 1.0.0-M5, use
* {@link CosmosDBVectorStore#builder(CosmosAsyncClient, EmbeddingModel)} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public void setVectorStoreThroughput(int vectorStoreThroughput) {
this.vectorStoreThroughput = vectorStoreThroughput;
}
/**
* @deprecated Since 1.0.0-M5, use
* {@link CosmosDBVectorStore#builder(CosmosAsyncClient, EmbeddingModel)} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public String getMetadataFields() {
return this.metadataFields;
}
/**
* @deprecated Since 1.0.0-M5, use
* {@link CosmosDBVectorStore#builder(CosmosAsyncClient, EmbeddingModel)} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public void setMetadataFields(String metadataFields) {
this.metadataFields = metadataFields;
this.metadataFieldsList = List.of(metadataFields.split(","));
}
/**
* @deprecated Since 1.0.0-M5, use
* {@link CosmosDBVectorStore#builder(CosmosAsyncClient, EmbeddingModel)} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public List<String> getMetadataFieldsList() {
return this.metadataFieldsList;
}
/**
* @deprecated Since 1.0.0-M5, use
* {@link CosmosDBVectorStore#builder(CosmosAsyncClient, EmbeddingModel)} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public String getEndpoint() {
return this.endpoint;
}
/**
* @deprecated Since 1.0.0-M5, use
* {@link CosmosDBVectorStore#builder(CosmosAsyncClient, EmbeddingModel)} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public void setEndpoint(String endpoint) {
this.endpoint = endpoint;
}
/**
* @deprecated Since 1.0.0-M5, use
* {@link CosmosDBVectorStore#builder(CosmosAsyncClient, EmbeddingModel)} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public String getKey() {
return this.key;
}
/**
* @deprecated Since 1.0.0-M5, use
* {@link CosmosDBVectorStore#builder(CosmosAsyncClient, EmbeddingModel)} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public void setKey(String key) {
this.key = key;
}
/**
* @deprecated Since 1.0.0-M5, use
* {@link CosmosDBVectorStore#builder(CosmosAsyncClient, EmbeddingModel)} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public String getContainerName() {
return this.containerName;
}
/**
* @deprecated Since 1.0.0-M5, use
* {@link CosmosDBVectorStore#builder(CosmosAsyncClient, EmbeddingModel)} )} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public void setContainerName(String containerName) {
this.containerName = containerName;
}
/**
* @deprecated Since 1.0.0-M5, use
* {@link CosmosDBVectorStore#builder(CosmosAsyncClient, EmbeddingModel)} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public String getDatabaseName() {
return this.databaseName;
}
/**
* @deprecated Since 1.0.0-M5, use
* {@link CosmosDBVectorStore#builder(CosmosAsyncClient, EmbeddingModel)} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public void setDatabaseName(String databaseName) {
this.databaseName = databaseName;
}
/**
* @deprecated Since 1.0.0-M5, use
* {@link CosmosDBVectorStore#builder(CosmosAsyncClient, EmbeddingModel)} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public String getPartitionKeyPath() {
return this.partitionKeyPath;
}
/**
* @deprecated Since 1.0.0-M5, use
* {@link CosmosDBVectorStore#builder(CosmosAsyncClient, EmbeddingModel)} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public void setPartitionKeyPath(String partitionKeyPath) {
this.partitionKeyPath = partitionKeyPath;
}
@Override
public void close() throws Exception {
}
/**
* @deprecated Since 1.0.0-M5, use
* {@link CosmosDBVectorStore#builder(CosmosAsyncClient, EmbeddingModel)} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public long getVectorDimensions() {
return this.vectorDimensions;
}
/**
* @deprecated Since 1.0.0-M5, use
* {@link CosmosDBVectorStore#builder(CosmosAsyncClient, EmbeddingModel)} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public void setVectorDimensions(long vectorDimensions) {
this.vectorDimensions = vectorDimensions;
}
}

View File

@@ -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.
@@ -132,59 +132,6 @@ public class AzureVectorStore extends AbstractObservationVectorStore implements
private String indexName;
/**
* Creates a new AzureVectorStore with basic configuration.
* @param searchIndexClient the Azure search index client
* @param embeddingModel the embedding model to use
* @param initializeSchema whether to initialize schema
* @deprecated Since 1.0.0-M5, use {@link #builder(SearchIndexClient, EmbeddingModel)}
* ()} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public AzureVectorStore(SearchIndexClient searchIndexClient, EmbeddingModel embeddingModel,
boolean initializeSchema) {
this(searchIndexClient, embeddingModel, initializeSchema, List.of());
}
/**
* Creates a new AzureVectorStore with metadata fields configuration.
* @param searchIndexClient the Azure search index client
* @param embeddingModel the embedding model to use
* @param initializeSchema whether to initialize schema
* @param filterMetadataFields list of metadata fields for filtering
* @deprecated Since 1.0.0-M5, use {@link #builder(SearchIndexClient, EmbeddingModel)}
* ()} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public AzureVectorStore(SearchIndexClient searchIndexClient, EmbeddingModel embeddingModel,
boolean initializeSchema, List<MetadataField> filterMetadataFields) {
this(searchIndexClient, embeddingModel, initializeSchema, filterMetadataFields, ObservationRegistry.NOOP, null,
new TokenCountBatchingStrategy());
}
/**
* Creates a new AzureVectorStore with full configuration.
* @param searchIndexClient the Azure search index client
* @param embeddingModel the embedding model to use
* @param initializeSchema whether to initialize schema
* @param filterMetadataFields list of metadata fields for filtering
* @param observationRegistry the observation registry
* @param customObservationConvention the custom observation convention
* @deprecated Since 1.0.0-M5, use {@link #builder(SearchIndexClient, EmbeddingModel)}
* ()} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public AzureVectorStore(SearchIndexClient searchIndexClient, EmbeddingModel embeddingModel,
boolean initializeSchema, List<MetadataField> filterMetadataFields, ObservationRegistry observationRegistry,
VectorStoreObservationConvention customObservationConvention, BatchingStrategy batchingStrategy) {
this(builder(searchIndexClient, embeddingModel).initializeSchema(initializeSchema)
.filterMetadataFields(filterMetadataFields)
.observationRegistry(observationRegistry)
.customObservationConvention(customObservationConvention)
.batchingStrategy(batchingStrategy));
}
/**
* Protected constructor that accepts a builder instance. This is the preferred way to
* create new AzureVectorStore instances.
@@ -210,44 +157,6 @@ public class AzureVectorStore extends AbstractObservationVectorStore implements
return new Builder(searchIndexClient, embeddingModel);
}
/**
* Change the Index Name.
* @param indexName The Azure VectorStore index name to use.
* @deprecated Since 1.0.0-M5, use {@link #builder(SearchIndexClient, EmbeddingModel)}
* ()} with {@link Builder#indexName(String)} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public void setIndexName(String indexName) {
Assert.hasText(indexName, "The index name can not be empty.");
this.indexName = indexName;
}
/**
* Sets the a default maximum number of similar documents returned.
* @param topK The default maximum number of similar documents returned.
* @deprecated Since 1.0.0-M5, use {@link #builder(SearchIndexClient, EmbeddingModel)}
* ()} with {@link Builder#indexName(String)} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public void setDefaultTopK(int topK) {
Assert.isTrue(topK >= 0, "The topK should be positive value.");
this.defaultTopK = topK;
}
/**
* Sets the a default similarity threshold for returned documents.
* @param similarityThreshold The a default similarity threshold for returned
* documents.
* @deprecated Since 1.0.0-M5, use {@link #builder(SearchIndexClient, EmbeddingModel)}
* ()} with {@link Builder#indexName(String)} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public void setDefaultSimilarityThreshold(Double similarityThreshold) {
Assert.isTrue(similarityThreshold >= 0.0 && similarityThreshold <= 1.0,
"The similarity threshold must be in range [0.0:1.00].");
this.defaultSimilarityThreshold = similarityThreshold;
}
@Override
public void doAdd(List<Document> documents) {

View File

@@ -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.
@@ -227,31 +227,6 @@ public class CassandraVectorStore extends AbstractObservationVectorStore impleme
private final Similarity similarity;
// TODO: Remove this flag as the document no longer holds embeddings.
@Deprecated(since = "1.0.0-M5", forRemoval = true)
private final boolean returnEmbeddings;
/**
* @deprecated since 1.0.0-M5, use {@link #builder(EmbeddingModel)} ()} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public CassandraVectorStore(CassandraVectorStoreConfig conf, EmbeddingModel embeddingModel) {
this(conf, embeddingModel, ObservationRegistry.NOOP, null, new TokenCountBatchingStrategy());
}
/**
* @deprecated since 1.0.0-M5, use {@link #builder(EmbeddingModel)} ()} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public CassandraVectorStore(CassandraVectorStoreConfig conf, EmbeddingModel embeddingModel,
ObservationRegistry observationRegistry, VectorStoreObservationConvention customObservationConvention,
BatchingStrategy batchingStrategy) {
this(builder(embeddingModel).session(conf.session)
.observationRegistry(observationRegistry)
.customObservationConvention(customObservationConvention)
.batchingStrategy(batchingStrategy));
}
protected CassandraVectorStore(Builder builder) {
super(builder);
@@ -281,8 +256,6 @@ public class CassandraVectorStore extends AbstractObservationVectorStore impleme
this.filterExpressionConverter = builder.filterExpressionConverter != null ? builder.filterExpressionConverter
: new CassandraFilterExpressionConverter(cassandraMetadata.getColumns().values());
this.returnEmbeddings = builder.returnEmbeddings;
}
public static Builder builder(EmbeddingModel embeddingModel) {
@@ -471,9 +444,6 @@ public class CassandraVectorStore extends AbstractObservationVectorStore impleme
for (var m : this.schema.metadataColumns()) {
extraSelectFields.append(',').append(m.name());
}
if (this.returnEmbeddings) {
extraSelectFields.append(',').append(this.schema.embedding());
}
// java-driver-query-builder doesn't support orderByAnnOf yet
String query = String.format(QUERY_FORMAT, similarityFunction, ids.toString(), this.schema.content(),

View File

@@ -1,597 +0,0 @@
/*
* Copyright 2023-2024 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.
*/
package org.springframework.ai.vectorstore.cassandra;
import java.net.InetSocketAddress;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.function.Function;
import java.util.stream.Stream;
import com.datastax.oss.driver.api.core.CqlSession;
import com.datastax.oss.driver.api.core.CqlSessionBuilder;
import com.datastax.oss.driver.api.core.cql.SimpleStatement;
import com.datastax.oss.driver.api.core.metadata.schema.ColumnMetadata;
import com.datastax.oss.driver.api.core.metadata.schema.TableMetadata;
import com.datastax.oss.driver.api.core.type.DataType;
import com.datastax.oss.driver.api.core.type.DataTypes;
import com.datastax.oss.driver.api.core.type.codec.registry.CodecRegistry;
import com.datastax.oss.driver.api.core.type.reflect.GenericType;
import com.datastax.oss.driver.api.querybuilder.BuildableQuery;
import com.datastax.oss.driver.api.querybuilder.SchemaBuilder;
import com.datastax.oss.driver.api.querybuilder.schema.AlterTableAddColumn;
import com.datastax.oss.driver.api.querybuilder.schema.AlterTableAddColumnEnd;
import com.datastax.oss.driver.api.querybuilder.schema.CreateTable;
import com.datastax.oss.driver.api.querybuilder.schema.CreateTableStart;
import com.datastax.oss.driver.shaded.guava.common.annotations.VisibleForTesting;
import com.datastax.oss.driver.shaded.guava.common.base.Preconditions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.ai.cassandra.SchemaUtil;
import org.springframework.ai.embedding.EmbeddingModel;
import org.springframework.lang.Nullable;
/**
* Configuration for the Cassandra vector store.
*
* All metadata columns configured to the store will be fetched and added to all queried
* documents.
*
* To filter expression search against a metadata column configure it with
* SchemaColumnTags.INDEXED
*
* The Cassandra Java Driver is configured via the application.conf resource found in the
* classpath. See
* https://github.com/apache/cassandra-java-driver/tree/4.x/manual/core/configuration
*
* @author Mick Semb Wever
* @since 1.0.0
* @deprecated since 1.0.0-M5, use {@link CassandraVectorStore#builder(EmbeddingModel)}
* instead.
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public final class CassandraVectorStoreConfig implements AutoCloseable {
public static final String DEFAULT_KEYSPACE_NAME = "springframework";
public static final String DEFAULT_TABLE_NAME = "ai_vector_store";
public static final String DEFAULT_ID_NAME = "id";
public static final String DEFAULT_INDEX_SUFFIX = "idx";
public static final String DEFAULT_CONTENT_COLUMN_NAME = "content";
public static final String DEFAULT_EMBEDDING_COLUMN_NAME = "embedding";
public static final int DEFAULT_ADD_CONCURRENCY = 16;
private static final Logger logger = LoggerFactory.getLogger(CassandraVectorStoreConfig.class);
final CqlSession session;
final Schema schema;
final boolean disallowSchemaChanges;
// TODO: Remove this flag as the document no longer holds embeddings.
@Deprecated(since = "1.0.0-M5", forRemoval = true)
final boolean returnEmbeddings;
final DocumentIdTranslator documentIdTranslator;
final PrimaryKeyTranslator primaryKeyTranslator;
final Executor executor;
private final boolean closeSessionOnClose;
private CassandraVectorStoreConfig(Builder builder) {
this.session = null != builder.session ? builder.session : builder.sessionBuilder.build();
this.closeSessionOnClose = null == builder.session;
this.schema = new Schema(builder.keyspace, builder.table, builder.partitionKeys, builder.clusteringKeys,
builder.contentColumnName, builder.embeddingColumnName, builder.indexName, builder.metadataColumns);
this.disallowSchemaChanges = builder.disallowSchemaChanges;
this.returnEmbeddings = builder.returnEmbeddings;
this.documentIdTranslator = builder.documentIdTranslator;
this.primaryKeyTranslator = builder.primaryKeyTranslator;
this.executor = Executors.newFixedThreadPool(builder.fixedThreadPoolExecutorSize);
}
public static Builder builder() {
return new Builder();
}
@Override
public void close() throws Exception {
if (this.closeSessionOnClose) {
this.session.close();
}
}
SchemaColumn getPrimaryKeyColumn(int index) {
return index < this.schema.partitionKeys().size() ? this.schema.partitionKeys().get(index)
: this.schema.clusteringKeys().get(index - this.schema.partitionKeys().size());
}
@VisibleForTesting
void dropKeyspace() {
Preconditions.checkState(this.schema.keyspace.startsWith("test_"), "Only test keyspaces can be dropped");
this.session.execute(SchemaBuilder.dropKeyspace(this.schema.keyspace).ifExists().build());
}
void ensureSchemaExists(int vectorDimension) {
if (!this.disallowSchemaChanges) {
SchemaUtil.ensureKeyspaceExists(this.session, this.schema.keyspace);
ensureTableExists(vectorDimension);
ensureTableColumnsExist(vectorDimension);
ensureIndexesExists();
SchemaUtil.checkSchemaAgreement(this.session);
}
else {
checkSchemaValid(vectorDimension);
}
}
void checkSchemaValid(int vectorDimension) {
Preconditions.checkState(this.session.getMetadata().getKeyspace(this.schema.keyspace).isPresent(),
"keyspace %s does not exist", this.schema.keyspace);
Preconditions.checkState(this.session.getMetadata()
.getKeyspace(this.schema.keyspace)
.get()
.getTable(this.schema.table)
.isPresent(), "table %s does not exist");
TableMetadata tableMetadata = this.session.getMetadata()
.getKeyspace(this.schema.keyspace)
.get()
.getTable(this.schema.table)
.get();
Preconditions.checkState(tableMetadata.getColumn(this.schema.content).isPresent(), "column %s does not exist",
this.schema.content);
Preconditions.checkState(tableMetadata.getColumn(this.schema.embedding).isPresent(), "column %s does not exist",
this.schema.embedding);
for (SchemaColumn m : this.schema.metadataColumns) {
Optional<ColumnMetadata> column = tableMetadata.getColumn(m.name());
Preconditions.checkState(column.isPresent(), "column %s does not exist", m.name());
Preconditions.checkArgument(column.get().getType().equals(m.type()),
"Mismatching type on metadata column %s of %s vs %s", m.name(), column.get().getType(), m.type());
if (m.indexed()) {
Preconditions.checkState(
tableMetadata.getIndexes().values().stream().anyMatch(i -> i.getTarget().equals(m.name())),
"index %s does not exist", m.name());
}
}
}
private void ensureIndexesExists() {
SimpleStatement indexStmt = SchemaBuilder.createIndex(this.schema.index)
.ifNotExists()
.custom("StorageAttachedIndex")
.onTable(this.schema.keyspace, this.schema.table)
.andColumn(this.schema.embedding)
.build();
logger.debug("Executing {}", indexStmt.getQuery());
this.session.execute(indexStmt);
Stream
.concat(this.schema.partitionKeys.stream(),
Stream.concat(this.schema.clusteringKeys.stream(), this.schema.metadataColumns.stream()))
.filter(cs -> cs.indexed())
.forEach(metadata -> {
SimpleStatement indexStatement = SchemaBuilder.createIndex(String.format("%s_idx", metadata.name()))
.ifNotExists()
.custom("StorageAttachedIndex")
.onTable(this.schema.keyspace, this.schema.table)
.andColumn(metadata.name())
.build();
logger.debug("Executing {}", indexStatement.getQuery());
this.session.execute(indexStatement);
});
}
private void ensureTableExists(int vectorDimension) {
if (this.session.getMetadata().getKeyspace(this.schema.keyspace).get().getTable(this.schema.table).isEmpty()) {
CreateTable createTable = null;
CreateTableStart createTableStart = SchemaBuilder.createTable(this.schema.keyspace, this.schema.table)
.ifNotExists();
for (SchemaColumn partitionKey : this.schema.partitionKeys) {
createTable = (null != createTable ? createTable : createTableStart).withPartitionKey(partitionKey.name,
partitionKey.type);
}
for (SchemaColumn clusteringKey : this.schema.clusteringKeys) {
createTable = createTable.withClusteringColumn(clusteringKey.name, clusteringKey.type);
}
createTable = createTable.withColumn(this.schema.content, DataTypes.TEXT);
for (SchemaColumn metadata : this.schema.metadataColumns) {
createTable = createTable.withColumn(metadata.name(), metadata.type());
}
// https://datastax-oss.atlassian.net/browse/JAVA-3118
// .withColumn(config.embedding, new DefaultVectorType(DataTypes.FLOAT,
// vectorDimension));
StringBuilder tableStmt = new StringBuilder(createTable.asCql());
tableStmt.setLength(tableStmt.length() - 1);
tableStmt.append(',')
.append(this.schema.embedding)
.append(" vector<float,")
.append(vectorDimension)
.append(">)");
logger.debug("Executing {}", tableStmt.toString());
this.session.execute(tableStmt.toString());
}
}
private void ensureTableColumnsExist(int vectorDimension) {
TableMetadata tableMetadata = this.session.getMetadata()
.getKeyspace(this.schema.keyspace)
.get()
.getTable(this.schema.table)
.get();
Set<SchemaColumn> newColumns = new HashSet<>();
boolean addContent = tableMetadata.getColumn(this.schema.content).isEmpty();
boolean addEmbedding = tableMetadata.getColumn(this.schema.embedding).isEmpty();
for (SchemaColumn metadata : this.schema.metadataColumns) {
Optional<ColumnMetadata> column = tableMetadata.getColumn(metadata.name());
if (column.isPresent()) {
Preconditions.checkArgument(column.get().getType().equals(metadata.type()),
"Cannot change type on metadata column %s from %s to %s", metadata.name(),
column.get().getType(), metadata.type());
}
else {
newColumns.add(metadata);
}
}
if (!newColumns.isEmpty() || addContent || addEmbedding) {
AlterTableAddColumn alterTable = SchemaBuilder.alterTable(this.schema.keyspace, this.schema.table);
for (SchemaColumn metadata : newColumns) {
alterTable = alterTable.addColumn(metadata.name(), metadata.type());
}
if (addContent) {
alterTable = alterTable.addColumn(this.schema.content, DataTypes.TEXT);
}
if (addEmbedding) {
// special case for embedding column, bc JAVA-3118, as above
StringBuilder alterTableStmt = new StringBuilder(((BuildableQuery) alterTable).asCql());
if (newColumns.isEmpty() && !addContent) {
alterTableStmt.append(" ADD (");
}
else {
alterTableStmt.setLength(alterTableStmt.length() - 1);
alterTableStmt.append(',');
}
alterTableStmt.append(this.schema.embedding)
.append(" vector<float,")
.append(vectorDimension)
.append(">)");
logger.debug("Executing {}", alterTableStmt.toString());
this.session.execute(alterTableStmt.toString());
}
else {
SimpleStatement stmt = ((AlterTableAddColumnEnd) alterTable).build();
logger.debug("Executing {}", stmt.getQuery());
this.session.execute(stmt);
}
}
}
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public enum SchemaColumnTags {
INDEXED
}
/**
* Given a string document id, return the value for each primary key column.
*
* It is a requirement that an empty {@code List<Object>} returns an example formatted
* id
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public interface DocumentIdTranslator extends Function<String, List<Object>> {
}
@Deprecated(since = "1.0.0-M5", forRemoval = true)
/** Given a list of primary key column values, return the document id. */
public interface PrimaryKeyTranslator extends Function<List<Object>, String> {
}
@Deprecated(since = "1.0.0-M5", forRemoval = true)
record Schema(String keyspace, String table, List<SchemaColumn> partitionKeys, List<SchemaColumn> clusteringKeys,
String content, String embedding, String index, Set<SchemaColumn> metadataColumns) {
}
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public record SchemaColumn(String name, DataType type, SchemaColumnTags... tags) {
public SchemaColumn(String name, DataType type) {
this(name, type, new SchemaColumnTags[0]);
}
public GenericType<Object> javaType() {
return CodecRegistry.DEFAULT.codecFor(this.type).getJavaType();
}
public boolean indexed() {
for (SchemaColumnTags t : this.tags) {
if (SchemaColumnTags.INDEXED == t) {
return true;
}
}
return false;
}
}
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public static final class Builder {
private CqlSession session = null;
private CqlSessionBuilder sessionBuilder = null;
private String keyspace = DEFAULT_KEYSPACE_NAME;
private String table = DEFAULT_TABLE_NAME;
private List<SchemaColumn> partitionKeys = List.of(new SchemaColumn(DEFAULT_ID_NAME, DataTypes.TEXT));
private List<SchemaColumn> clusteringKeys = List.of();
private String indexName = null;
private String contentColumnName = DEFAULT_CONTENT_COLUMN_NAME;
private String embeddingColumnName = DEFAULT_EMBEDDING_COLUMN_NAME;
private Set<SchemaColumn> metadataColumns = new HashSet<>();
private boolean disallowSchemaChanges = false;
private boolean returnEmbeddings = false;
private int fixedThreadPoolExecutorSize = DEFAULT_ADD_CONCURRENCY;
private DocumentIdTranslator documentIdTranslator = (String id) -> List.of(id);
private PrimaryKeyTranslator primaryKeyTranslator = (List<Object> primaryKeyColumns) -> {
if (primaryKeyColumns.isEmpty()) {
return "test";
}
Preconditions.checkArgument(1 == primaryKeyColumns.size());
return (String) primaryKeyColumns.get(0);
};
private Builder() {
}
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public Builder withCqlSession(CqlSession session) {
Preconditions.checkState(null == this.sessionBuilder,
"Cannot call withContactPoint(..) or withLocalDatacenter(..) and this method");
this.session = session;
return this;
}
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public Builder addContactPoint(InetSocketAddress contactPoint) {
Preconditions.checkState(null == this.session, "Cannot call withCqlSession(..) and this method");
if (null == this.sessionBuilder) {
this.sessionBuilder = new CqlSessionBuilder();
}
this.sessionBuilder.addContactPoint(contactPoint);
return this;
}
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public Builder withLocalDatacenter(String localDC) {
Preconditions.checkState(null == this.session, "Cannot call withCqlSession(..) and this method");
if (null == this.sessionBuilder) {
this.sessionBuilder = new CqlSessionBuilder();
}
this.sessionBuilder.withLocalDatacenter(localDC);
return this;
}
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public Builder withKeyspaceName(String keyspace) {
this.keyspace = keyspace;
return this;
}
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public Builder withTableName(String table) {
this.table = table;
return this;
}
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public Builder withPartitionKeys(List<SchemaColumn> partitionKeys) {
Preconditions.checkArgument(!partitionKeys.isEmpty());
this.partitionKeys = partitionKeys;
return this;
}
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public Builder withClusteringKeys(List<SchemaColumn> clusteringKeys) {
this.clusteringKeys = clusteringKeys;
return this;
}
/**
* defaults (if null) to '&lt;table_name&gt;_&lt;embedding_column_name&gt;_idx'
**/
@Nullable
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public Builder withIndexName(String name) {
this.indexName = name;
return this;
}
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public Builder withContentColumnName(String name) {
this.contentColumnName = name;
return this;
}
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public Builder withEmbeddingColumnName(String name) {
this.embeddingColumnName = name;
return this;
}
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public Builder addMetadataColumns(SchemaColumn... columns) {
Builder builder = this;
for (SchemaColumn f : columns) {
builder = builder.addMetadataColumn(f);
}
return builder;
}
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public Builder addMetadataColumns(List<SchemaColumn> columns) {
Builder builder = this;
this.metadataColumns.addAll(columns);
return builder;
}
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public Builder addMetadataColumn(SchemaColumn column) {
Preconditions.checkArgument(this.metadataColumns.stream().noneMatch(sc -> sc.name().equals(column.name())),
"A metadata column with name %s has already been added", column.name());
this.metadataColumns.add(column);
return this;
}
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public Builder disallowSchemaChanges() {
this.disallowSchemaChanges = true;
return this;
}
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public Builder returnEmbeddings() {
this.returnEmbeddings = true;
return this;
}
/**
* Executor to use when adding documents. The hotspot is the call to the
* embeddingModel. For remote transformers you probably want a higher value to
* utilize network. For local transformers you probably want a lower value to
* avoid saturation.
**/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public Builder withFixedThreadPoolExecutorSize(int threads) {
Preconditions.checkArgument(0 < threads);
this.fixedThreadPoolExecutorSize = threads;
return this;
}
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public Builder withDocumentIdTranslator(DocumentIdTranslator documentIdTranslator) {
this.documentIdTranslator = documentIdTranslator;
return this;
}
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public Builder withPrimaryKeyTranslator(PrimaryKeyTranslator primaryKeyTranslator) {
this.primaryKeyTranslator = primaryKeyTranslator;
return this;
}
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public CassandraVectorStoreConfig build() {
if (null == this.indexName) {
this.indexName = String.format("%s_%s_%s", this.table, this.embeddingColumnName, DEFAULT_INDEX_SUFFIX);
}
for (SchemaColumn metadata : this.metadataColumns) {
Preconditions.checkArgument(
!this.partitionKeys.stream().anyMatch(c -> c.name().equals(metadata.name())),
"metadataColumn %s cannot have same name as a partition key", metadata.name());
Preconditions.checkArgument(
!this.clusteringKeys.stream().anyMatch(c -> c.name().equals(metadata.name())),
"metadataColumn %s cannot have same name as a clustering key", metadata.name());
Preconditions.checkArgument(!metadata.name().equals(this.contentColumnName),
"metadataColumn %s cannot have same name as content column name", this.contentColumnName);
Preconditions.checkArgument(!metadata.name().equals(this.embeddingColumnName),
"metadataColumn %s cannot have same name as embedding column name", this.embeddingColumnName);
}
int primaryKeyColumnsCount = this.partitionKeys.size() + this.clusteringKeys.size();
String exampleId = this.primaryKeyTranslator.apply(Collections.emptyList());
List<Object> testIdTranslation = this.documentIdTranslator.apply(exampleId);
Preconditions.checkArgument(testIdTranslation.size() == primaryKeyColumnsCount,
"documentIdTranslator results length %s doesn't match number of primary key columns %s",
String.valueOf(testIdTranslation.size()), String.valueOf(primaryKeyColumnsCount));
Preconditions.checkArgument(
exampleId.equals(this.primaryKeyTranslator.apply(this.documentIdTranslator.apply(exampleId))),
"primaryKeyTranslator is not an inverse function to documentIdTranslator");
return new CassandraVectorStoreConfig(this);
}
}
}

View File

@@ -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.
@@ -85,30 +85,6 @@ public class ChromaVectorStore extends AbstractObservationVectorStore implements
private boolean initialized = false;
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public ChromaVectorStore(EmbeddingModel embeddingModel, ChromaApi chromaApi, boolean initializeSchema) {
this(embeddingModel, chromaApi, DEFAULT_COLLECTION_NAME, initializeSchema);
}
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public ChromaVectorStore(EmbeddingModel embeddingModel, ChromaApi chromaApi, String collectionName,
boolean initializeSchema) {
this(embeddingModel, chromaApi, collectionName, initializeSchema, ObservationRegistry.NOOP, null,
new TokenCountBatchingStrategy());
}
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public ChromaVectorStore(EmbeddingModel embeddingModel, ChromaApi chromaApi, String collectionName,
boolean initializeSchema, ObservationRegistry observationRegistry,
@Nullable VectorStoreObservationConvention customObservationConvention, BatchingStrategy batchingStrategy) {
this(builder(chromaApi, embeddingModel).collectionName(collectionName)
.initializeSchema(initializeSchema)
.observationRegistry(observationRegistry)
.customObservationConvention(customObservationConvention)
.batchingStrategy(batchingStrategy));
}
/**
* @param builder {@link VectorStore.Builder} for chroma vector store
*/
@@ -241,32 +217,6 @@ public class ChromaVectorStore extends AbstractObservationVectorStore implements
}
}
/**
* @deprecated not used currently anywhere
*/
@Deprecated(forRemoval = true)
public String getCollectionName() {
return this.collectionName;
}
/**
* @deprecated only used in tests
*/
@Deprecated(forRemoval = true)
@Nullable
public String getCollectionId() {
return this.collectionId;
}
/**
* @deprecated in favor the builder method
*/
@Deprecated(forRemoval = true)
public void setFilterExpressionConverter(FilterExpressionConverter filterExpressionConverter) {
Assert.notNull(filterExpressionConverter, "FilterExpressionConverter should not be null.");
this.filterExpressionConverter = filterExpressionConverter;
}
@Override
public VectorStoreObservationContext.Builder createObservationContextBuilder(String operationName) {
return VectorStoreObservationContext.builder(VectorStoreProvider.CHROMA.value(), operationName)

View File

@@ -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.
@@ -166,30 +166,6 @@ public class ElasticsearchVectorStore extends AbstractObservationVectorStore imp
private final BatchingStrategy batchingStrategy;
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public ElasticsearchVectorStore(RestClient restClient, EmbeddingModel embeddingModel, boolean initializeSchema) {
this(new ElasticsearchVectorStoreOptions(), restClient, embeddingModel, initializeSchema);
}
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public ElasticsearchVectorStore(ElasticsearchVectorStoreOptions options, RestClient restClient,
EmbeddingModel embeddingModel, boolean initializeSchema) {
this(options, restClient, embeddingModel, initializeSchema, ObservationRegistry.NOOP, null,
new TokenCountBatchingStrategy());
}
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public ElasticsearchVectorStore(ElasticsearchVectorStoreOptions options, RestClient restClient,
EmbeddingModel embeddingModel, boolean initializeSchema, ObservationRegistry observationRegistry,
VectorStoreObservationConvention customObservationConvention, BatchingStrategy batchingStrategy) {
this(builder(restClient, embeddingModel).options(options)
.initializeSchema(initializeSchema)
.observationRegistry(observationRegistry)
.customObservationConvention(customObservationConvention)
.batchingStrategy(batchingStrategy));
}
protected ElasticsearchVectorStore(Builder builder) {
super(builder);

View File

@@ -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.
@@ -121,49 +121,6 @@ public class GemFireVectorStore extends AbstractObservationVectorStore implement
private final String[] fields;
/**
* Creates a new GemFireVectorStore with basic configuration.
* @param config the vector store configuration
* @param embeddingModel the embedding model to use
* @param initializeSchema whether to initialize schema
* @deprecated Since 1.0.0-M5, use {@link #builder(EmbeddingModel)} ()} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public GemFireVectorStore(GemFireVectorStoreConfig config, EmbeddingModel embeddingModel,
boolean initializeSchema) {
this(config, embeddingModel, initializeSchema, ObservationRegistry.NOOP, null,
new TokenCountBatchingStrategy());
}
/**
* Creates a new GemFireVectorStore with observation configuration.
* @param config the vector store configuration
* @param embeddingModel the embedding model to use
* @param initializeSchema whether to initialize schema
* @param observationRegistry the observation registry
* @param customObservationConvention the custom observation convention
* @deprecated Since 1.0.0-M5, use {@link #builder(EmbeddingModel)} ()} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public GemFireVectorStore(GemFireVectorStoreConfig config, EmbeddingModel embeddingModel, boolean initializeSchema,
ObservationRegistry observationRegistry, VectorStoreObservationConvention customObservationConvention,
BatchingStrategy batchingStrategy) {
this(builder(embeddingModel).host(config.host)
.port(config.port)
.sslEnabled(config.sslEnabled)
.indexName(config.indexName)
.beamWidth(config.beamWidth)
.maxConnections(config.maxConnections)
.buckets(config.buckets)
.vectorSimilarityFunction(config.vectorSimilarityFunction)
.fields(config.fields)
.initializeSchema(initializeSchema)
.observationRegistry(observationRegistry)
.customObservationConvention(customObservationConvention)
.batchingStrategy(batchingStrategy));
}
/**
* Protected constructor that accepts a builder instance. This is the preferred way to
* create new GemFireVectorStore instances.
@@ -600,225 +557,6 @@ public class GemFireVectorStore extends AbstractObservationVectorStore implement
}
/**
* Configuration class for GemFire Vector Store.
*
* @deprecated Since 1.0.0-M5, use {@link GemFireVectorStore#builder(EmbeddingModel)}
* instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public static final class GemFireVectorStoreConfig {
// Create Index DEFAULT Values
public static final String DEFAULT_HOST = "localhost";
public static final int DEFAULT_PORT = 8080;
public static final String DEFAULT_INDEX_NAME = "spring-ai-gemfire-index";
public static final int UPPER_BOUND_BEAM_WIDTH = 3200;
public static final int DEFAULT_BEAM_WIDTH = 100;
private static final int UPPER_BOUND_MAX_CONNECTIONS = 512;
public static final int DEFAULT_MAX_CONNECTIONS = 16;
public static final String DEFAULT_SIMILARITY_FUNCTION = "COSINE";
public static final String[] DEFAULT_FIELDS = new String[] {};
public static final int DEFAULT_BUCKETS = 0;
public static final boolean DEFAULT_SSL_ENABLED = false;
String host;
int port;
String indexName;
int beamWidth;
int maxConnections;
String vectorSimilarityFunction;
String[] fields;
int buckets;
boolean sslEnabled;
/**
* @deprecated Since 1.0.0-M5, use
* {@link GemFireVectorStore#builder(EmbeddingModel)} ()} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
private GemFireVectorStoreConfig(Builder builder) {
this.host = builder.host;
this.port = builder.port;
this.sslEnabled = builder.sslEnabled;
this.indexName = builder.indexName;
this.beamWidth = builder.beamWidth;
this.maxConnections = builder.maxConnections;
this.buckets = builder.buckets;
this.vectorSimilarityFunction = builder.vectorSimilarityFunction;
this.fields = builder.fields;
}
/**
* Start building a new configuration.
* @return The entry point for creating a new configuration.
* @deprecated Since 1.0.0-M5, use
* {@link GemFireVectorStore#builder(EmbeddingModel)} ()} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public static Builder builder() {
return new Builder();
}
/**
* @deprecated Since 1.0.0-M5, use
* {@link GemFireVectorStore#builder(EmbeddingModel)} ()} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public static class Builder {
// Create Index DEFAULT Values
String host = GemFireVectorStoreConfig.DEFAULT_HOST;
int port = GemFireVectorStoreConfig.DEFAULT_PORT;
String indexName = GemFireVectorStoreConfig.DEFAULT_INDEX_NAME;
int beamWidth = GemFireVectorStoreConfig.DEFAULT_BEAM_WIDTH;
int maxConnections = GemFireVectorStoreConfig.DEFAULT_MAX_CONNECTIONS;
String vectorSimilarityFunction = GemFireVectorStoreConfig.DEFAULT_SIMILARITY_FUNCTION;
String[] fields = GemFireVectorStoreConfig.DEFAULT_FIELDS;
int buckets = GemFireVectorStoreConfig.DEFAULT_BUCKETS;
boolean sslEnabled = GemFireVectorStoreConfig.DEFAULT_SSL_ENABLED;
/**
* @deprecated Since 1.0.0-M5, use
* {@link GemFireVectorStore#builder(EmbeddingModel)} ()} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public Builder setHost(String host) {
Assert.hasText(host, "host must have a value");
this.host = host;
return this;
}
/**
* @deprecated Since 1.0.0-M5, use
* {@link GemFireVectorStore#builder(EmbeddingModel)} ()} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public Builder setPort(int port) {
Assert.isTrue(port > 0, "port must be positive");
this.port = port;
return this;
}
/**
* @deprecated Since 1.0.0-M5, use
* {@link GemFireVectorStore#builder(EmbeddingModel)} ()} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public Builder setSslEnabled(boolean sslEnabled) {
this.sslEnabled = sslEnabled;
return this;
}
/**
* @deprecated Since 1.0.0-M5, use
* {@link GemFireVectorStore#builder(EmbeddingModel)} ()} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public Builder setIndexName(String indexName) {
Assert.hasText(indexName, "indexName must have a value");
this.indexName = indexName;
return this;
}
/**
* @deprecated Since 1.0.0-M5, use
* {@link GemFireVectorStore#builder(EmbeddingModel)} ()} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public Builder setBeamWidth(int beamWidth) {
Assert.isTrue(beamWidth > 0, "beamWidth must be positive");
Assert.isTrue(beamWidth <= GemFireVectorStoreConfig.UPPER_BOUND_BEAM_WIDTH,
"beamWidth must be less than or equal to " + GemFireVectorStoreConfig.UPPER_BOUND_BEAM_WIDTH);
this.beamWidth = beamWidth;
return this;
}
/**
* @deprecated Since 1.0.0-M5, use
* {@link GemFireVectorStore#builder(EmbeddingModel)} ()} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public Builder setMaxConnections(int maxConnections) {
Assert.isTrue(maxConnections > 0, "maxConnections must be positive");
Assert.isTrue(maxConnections <= GemFireVectorStoreConfig.UPPER_BOUND_MAX_CONNECTIONS,
"maxConnections must be less than or equal to "
+ GemFireVectorStoreConfig.UPPER_BOUND_MAX_CONNECTIONS);
this.maxConnections = maxConnections;
return this;
}
/**
* @deprecated Since 1.0.0-M5, use
* {@link GemFireVectorStore#builder(EmbeddingModel)} ()} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public Builder setBuckets(int buckets) {
Assert.isTrue(buckets >= 0, "bucket must be 1 or more");
this.buckets = buckets;
return this;
}
/**
* @deprecated Since 1.0.0-M5, use
* {@link GemFireVectorStore#builder(EmbeddingModel)} ()} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public Builder setVectorSimilarityFunction(String vectorSimilarityFunction) {
Assert.hasText(vectorSimilarityFunction, "vectorSimilarityFunction must have a value");
this.vectorSimilarityFunction = vectorSimilarityFunction;
return this;
}
/**
* @deprecated Since 1.0.0-M5, use
* {@link GemFireVectorStore#builder(EmbeddingModel)} ()} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public Builder setFields(String[] fields) {
this.fields = fields;
return this;
}
/**
* @deprecated Since 1.0.0-M5, use
* {@link GemFireVectorStore#builder(EmbeddingModel)} ()} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public GemFireVectorStoreConfig build() {
return new GemFireVectorStoreConfig(this);
}
}
}
/**
* Builder class for creating {@link GemFireVectorStore} instances.
* <p>

View File

@@ -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.
@@ -89,41 +89,6 @@ public class HanaCloudVectorStore extends AbstractObservationVectorStore {
private final ObjectMapper objectMapper;
/**
* Creates a new HanaCloudVectorStore with basic configuration.
* @param repository the HANA vector repository
* @param embeddingModel the embedding model to use
* @param config the vector store configuration
* @deprecated Since 1.0.0-M5, use
* {@link #builder(HanaVectorRepository, EmbeddingModel)} ()} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public HanaCloudVectorStore(HanaVectorRepository<? extends HanaVectorEntity> repository,
EmbeddingModel embeddingModel, HanaCloudVectorStoreConfig config) {
this(repository, embeddingModel, config, ObservationRegistry.NOOP, null);
}
/**
* Creates a new HanaCloudVectorStore with observation configuration.
* @param repository the HANA vector repository
* @param embeddingModel the embedding model to use
* @param config the vector store configuration
* @param observationRegistry the observation registry
* @param customObservationConvention the custom observation convention
* @deprecated Since 1.0.0-M5, use
* {@link #builder(HanaVectorRepository, EmbeddingModel)} ()} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public HanaCloudVectorStore(HanaVectorRepository<? extends HanaVectorEntity> repository,
EmbeddingModel embeddingModel, HanaCloudVectorStoreConfig config, ObservationRegistry observationRegistry,
VectorStoreObservationConvention customObservationConvention) {
this(builder(repository, embeddingModel).tableName(config.getTableName())
.topK(config.getTopK())
.observationRegistry(observationRegistry)
.customObservationConvention(customObservationConvention));
}
/**
* Protected constructor that accepts a builder instance. This is the preferred way to
* create new HanaCloudVectorStore instances.

View File

@@ -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.
@@ -199,88 +199,6 @@ public class MariaDBVectorStore extends AbstractObservationVectorStore implement
private final int maxDocumentBatchSize;
/**
* @deprecated Use {@link #builder(JdbcTemplate, EmbeddingModel)} (JdbcTemplate)}
* instead
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public MariaDBVectorStore(JdbcTemplate jdbcTemplate, EmbeddingModel embeddingModel) {
this(jdbcTemplate, embeddingModel, INVALID_EMBEDDING_DIMENSION, MariaDBDistanceType.COSINE, false, false);
}
/**
* @deprecated Use {@link #builder(JdbcTemplate, EmbeddingModel)} (JdbcTemplate)}
* instead
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public MariaDBVectorStore(JdbcTemplate jdbcTemplate, EmbeddingModel embeddingModel, int dimensions) {
this(jdbcTemplate, embeddingModel, dimensions, MariaDBDistanceType.COSINE, false, false);
}
/**
* @deprecated Use {@link #builder(JdbcTemplate, EmbeddingModel)} (JdbcTemplate)}
* instead
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public MariaDBVectorStore(JdbcTemplate jdbcTemplate, EmbeddingModel embeddingModel, int dimensions,
MariaDBDistanceType distanceType, boolean removeExistingVectorStoreTable, boolean initializeSchema) {
this(DEFAULT_TABLE_NAME, jdbcTemplate, embeddingModel, dimensions, distanceType, removeExistingVectorStoreTable,
initializeSchema);
}
/**
* @deprecated Use {@link #builder(JdbcTemplate, EmbeddingModel)} (JdbcTemplate)}
* instead
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public MariaDBVectorStore(String vectorTableName, JdbcTemplate jdbcTemplate, EmbeddingModel embeddingModel,
int dimensions, MariaDBDistanceType distanceType, boolean removeExistingVectorStoreTable,
boolean initializeSchema) {
this(null, vectorTableName, DEFAULT_SCHEMA_VALIDATION, jdbcTemplate, embeddingModel, dimensions, distanceType,
removeExistingVectorStoreTable, initializeSchema);
}
/**
* @deprecated Use {@link #builder(JdbcTemplate, EmbeddingModel)} (JdbcTemplate)}
* instead
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
private MariaDBVectorStore(String schemaName, String vectorTableName, boolean vectorTableValidationsEnabled,
JdbcTemplate jdbcTemplate, EmbeddingModel embeddingModel, int dimensions, MariaDBDistanceType distanceType,
boolean removeExistingVectorStoreTable, boolean initializeSchema) {
this(schemaName, vectorTableName, vectorTableValidationsEnabled, jdbcTemplate, embeddingModel, dimensions,
distanceType, removeExistingVectorStoreTable, initializeSchema, ObservationRegistry.NOOP, null,
new TokenCountBatchingStrategy(), MAX_DOCUMENT_BATCH_SIZE, DEFAULT_COLUMN_EMBEDDING,
DEFAULT_COLUMN_METADATA, DEFAULT_COLUMN_ID, DEFAULT_COLUMN_CONTENT);
}
/**
* @deprecated Use {@link #builder(JdbcTemplate, EmbeddingModel)} (JdbcTemplate)}
* instead
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
private MariaDBVectorStore(String schemaName, String vectorTableName, boolean vectorTableValidationsEnabled,
JdbcTemplate jdbcTemplate, EmbeddingModel embeddingModel, int dimensions, MariaDBDistanceType distanceType,
boolean removeExistingVectorStoreTable, boolean initializeSchema, ObservationRegistry observationRegistry,
VectorStoreObservationConvention customObservationConvention, BatchingStrategy batchingStrategy,
int maxDocumentBatchSize, String contentFieldName, String embeddingFieldName, String idFieldName,
String metadataFieldName) {
this(builder(jdbcTemplate, embeddingModel).vectorTableName(vectorTableName)
.dimensions(dimensions)
.distanceType(distanceType)
.removeExistingVectorStoreTable(removeExistingVectorStoreTable)
.initializeSchema(initializeSchema)
.observationRegistry(observationRegistry)
.customObservationConvention(customObservationConvention)
.batchingStrategy(batchingStrategy)
.maxDocumentBatchSize(maxDocumentBatchSize)
.contentFieldName(contentFieldName)
.embeddingFieldName(embeddingFieldName)
.idFieldName(idFieldName)
.metadataFieldName(metadataFieldName));
}
/**
* Protected constructor for creating a MariaDBVectorStore instance using the builder
* pattern.
@@ -775,175 +693,6 @@ public class MariaDBVectorStore extends AbstractObservationVectorStore implement
}
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public static class Builder {
private String contentFieldName = DEFAULT_COLUMN_CONTENT;
private String embeddingFieldName = DEFAULT_COLUMN_EMBEDDING;
private String idFieldName = DEFAULT_COLUMN_ID;
private String metadataFieldName = DEFAULT_COLUMN_METADATA;
private final JdbcTemplate jdbcTemplate;
private final EmbeddingModel embeddingModel;
private String schemaName = null;
private String vectorTableName;
private boolean vectorTableValidationsEnabled = MariaDBVectorStore.DEFAULT_SCHEMA_VALIDATION;
private int dimensions = MariaDBVectorStore.INVALID_EMBEDDING_DIMENSION;
private MariaDBDistanceType distanceType = MariaDBDistanceType.COSINE;
private boolean removeExistingVectorStoreTable = false;
private boolean initializeSchema;
private ObservationRegistry observationRegistry = ObservationRegistry.NOOP;
private BatchingStrategy batchingStrategy = new TokenCountBatchingStrategy();
private int maxDocumentBatchSize = MAX_DOCUMENT_BATCH_SIZE;
@Nullable
private VectorStoreObservationConvention searchObservationConvention;
// Builder constructor with mandatory parameters
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public Builder(JdbcTemplate jdbcTemplate, EmbeddingModel embeddingModel) {
if (jdbcTemplate == null || embeddingModel == null) {
throw new IllegalArgumentException("JdbcTemplate and EmbeddingModel must not be null");
}
this.jdbcTemplate = jdbcTemplate;
this.embeddingModel = embeddingModel;
}
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public Builder withSchemaName(String schemaName) {
this.schemaName = schemaName;
return this;
}
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public Builder withVectorTableName(String vectorTableName) {
this.vectorTableName = vectorTableName;
return this;
}
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public Builder withVectorTableValidationsEnabled(boolean vectorTableValidationsEnabled) {
this.vectorTableValidationsEnabled = vectorTableValidationsEnabled;
return this;
}
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public Builder withDimensions(int dimensions) {
this.dimensions = dimensions;
return this;
}
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public Builder withDistanceType(MariaDBDistanceType distanceType) {
this.distanceType = distanceType;
return this;
}
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public Builder withRemoveExistingVectorStoreTable(boolean removeExistingVectorStoreTable) {
this.removeExistingVectorStoreTable = removeExistingVectorStoreTable;
return this;
}
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public Builder withInitializeSchema(boolean initializeSchema) {
this.initializeSchema = initializeSchema;
return this;
}
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public Builder withObservationRegistry(ObservationRegistry observationRegistry) {
this.observationRegistry = observationRegistry;
return this;
}
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public Builder withSearchObservationConvention(VectorStoreObservationConvention customObservationConvention) {
this.searchObservationConvention = customObservationConvention;
return this;
}
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public Builder withBatchingStrategy(BatchingStrategy batchingStrategy) {
this.batchingStrategy = batchingStrategy;
return this;
}
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public Builder withMaxDocumentBatchSize(int maxDocumentBatchSize) {
this.maxDocumentBatchSize = maxDocumentBatchSize;
return this;
}
/**
* Configures the content field name to use.
* @param name the content field name to use
* @return this builder
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public Builder withContentFieldName(String name) {
this.contentFieldName = name;
return this;
}
/**
* Configures the embedding field name to use.
* @param name the embedding field name to use
* @return this builder
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public Builder withEmbeddingFieldName(String name) {
this.embeddingFieldName = name;
return this;
}
/**
* Configures the id field name to use.
* @param name the id field name to use
* @return this builder
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public Builder withIdFieldName(String name) {
this.idFieldName = name;
return this;
}
/**
* Configures the metadata field name to use.
* @param name the metadata field name to use
* @return this builder
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public Builder withMetadataFieldName(String name) {
this.metadataFieldName = name;
return this;
}
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public MariaDBVectorStore build() {
return new MariaDBVectorStore(this.schemaName, this.vectorTableName, this.vectorTableValidationsEnabled,
this.jdbcTemplate, this.embeddingModel, this.dimensions, this.distanceType,
this.removeExistingVectorStoreTable, this.initializeSchema, this.observationRegistry,
this.searchObservationConvention, this.batchingStrategy, this.maxDocumentBatchSize,
this.contentFieldName, this.embeddingFieldName, this.idFieldName, this.metadataFieldName);
}
}
/**
* The representation of {@link Document} along with its embedding.
*

View File

@@ -174,9 +174,6 @@ public class MilvusVectorStore extends AbstractObservationVectorStore implements
private final MilvusServiceClient milvusClient;
@Deprecated(forRemoval = true, since = "1.0.0-M5")
private final MilvusVectorStoreConfig config;
private final boolean initializeSchema;
private final BatchingStrategy batchingStrategy;
@@ -203,36 +200,6 @@ public class MilvusVectorStore extends AbstractObservationVectorStore implements
private final String embeddingFieldName;
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public MilvusVectorStore(MilvusServiceClient milvusClient, EmbeddingModel embeddingModel,
boolean initializeSchema) {
this(milvusClient, embeddingModel, MilvusVectorStoreConfig.defaultConfig(), initializeSchema,
new TokenCountBatchingStrategy());
}
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public MilvusVectorStore(MilvusServiceClient milvusClient, EmbeddingModel embeddingModel, boolean initializeSchema,
BatchingStrategy batchingStrategy) {
this(milvusClient, embeddingModel, MilvusVectorStoreConfig.defaultConfig(), initializeSchema, batchingStrategy);
}
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public MilvusVectorStore(MilvusServiceClient milvusClient, EmbeddingModel embeddingModel,
MilvusVectorStoreConfig config, boolean initializeSchema, BatchingStrategy batchingStrategy) {
this(milvusClient, embeddingModel, config, initializeSchema, batchingStrategy, ObservationRegistry.NOOP, null);
}
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public MilvusVectorStore(MilvusServiceClient milvusClient, EmbeddingModel embeddingModel,
MilvusVectorStoreConfig config, boolean initializeSchema, BatchingStrategy batchingStrategy,
ObservationRegistry observationRegistry, VectorStoreObservationConvention customObservationConvention) {
this(builder(milvusClient, embeddingModel).observationRegistry(observationRegistry)
.customObservationConvention(customObservationConvention)
.initializeSchema(initializeSchema)
.batchingStrategy(batchingStrategy));
}
/**
* @param builder {@link VectorStore.Builder} for chroma vector store
*/
@@ -244,7 +211,6 @@ public class MilvusVectorStore extends AbstractObservationVectorStore implements
this.milvusClient = builder.milvusClient;
this.batchingStrategy = builder.batchingStrategy;
this.initializeSchema = builder.initializeSchema;
this.config = null;
this.databaseName = builder.databaseName;
this.collectionName = builder.collectionName;
this.embeddingDimension = builder.embeddingDimension;
@@ -773,224 +739,4 @@ public class MilvusVectorStore extends AbstractObservationVectorStore implements
}
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public static final class MilvusVectorStoreConfig {
private final String databaseName;
private final String collectionName;
private final int embeddingDimension;
private final IndexType indexType;
private final MetricType metricType;
private final String indexParameters;
private final String idFieldName;
private final boolean isAutoId;
private final String contentFieldName;
private final String metadataFieldName;
private final String embeddingFieldName;
private MilvusVectorStoreConfig(Builder builder) {
this.databaseName = builder.databaseName;
this.collectionName = builder.collectionName;
this.embeddingDimension = builder.embeddingDimension;
this.indexType = builder.indexType;
this.metricType = builder.metricType;
this.indexParameters = builder.indexParameters;
this.idFieldName = builder.idFieldName;
this.isAutoId = builder.isAutoId;
this.contentFieldName = builder.contentFieldName;
this.metadataFieldName = builder.metadataFieldName;
this.embeddingFieldName = builder.embeddingFieldName;
}
/**
* Start building a new configuration.
* @return The entry point for creating a new configuration.
*/
public static Builder builder() {
return new Builder();
}
/**
* {@return the default config}
*/
public static MilvusVectorStoreConfig defaultConfig() {
return builder().build();
}
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public static final class Builder {
private String databaseName = DEFAULT_DATABASE_NAME;
private String collectionName = DEFAULT_COLLECTION_NAME;
private int embeddingDimension = INVALID_EMBEDDING_DIMENSION;
private IndexType indexType = IndexType.IVF_FLAT;
private MetricType metricType = MetricType.COSINE;
private String indexParameters = "{\"nlist\":1024}";
private String idFieldName = DOC_ID_FIELD_NAME;
private boolean isAutoId = false;
private String contentFieldName = CONTENT_FIELD_NAME;
private String metadataFieldName = METADATA_FIELD_NAME;
private String embeddingFieldName = EMBEDDING_FIELD_NAME;
private Builder() {
}
/**
* Configures the Milvus metric type to use. Leave {@literal null} or blank to
* use the metric metric: https://milvus.io/docs/metric.md#floating
* @param metricType the metric type to use
* @return this builder
*/
public Builder withMetricType(MetricType metricType) {
Assert.notNull(metricType, "Collection Name must not be empty");
Assert.isTrue(
metricType == MetricType.IP || metricType == MetricType.L2 || metricType == MetricType.COSINE,
"Only the text metric types IP and L2 are supported");
this.metricType = metricType;
return this;
}
/**
* Configures the Milvus index type to use. Leave {@literal null} or blank to
* use the default index.
* @param indexType the index type to use
* @return this builder
*/
public Builder withIndexType(IndexType indexType) {
this.indexType = indexType;
return this;
}
/**
* Configures the Milvus index parameters to use. Leave {@literal null} or
* blank to use the default index parameters.
* @param indexParameters the index parameters to use
* @return this builder
*/
public Builder withIndexParameters(String indexParameters) {
this.indexParameters = indexParameters;
return this;
}
/**
* Configures the Milvus database name to use. Leave {@literal null} or blank
* to use the default database.
* @param databaseName the database name to use
* @return this builder
*/
public Builder withDatabaseName(String databaseName) {
this.databaseName = databaseName;
return this;
}
/**
* Configures the Milvus collection name to use. Leave {@literal null} or
* blank to use the default collection name.
* @param collectionName the collection name to use
* @return this builder
*/
public Builder withCollectionName(String collectionName) {
this.collectionName = collectionName;
return this;
}
/**
* Configures the size of the embedding. Defaults to {@literal 1536}, inline
* with OpenAIs embeddings.
* @param newEmbeddingDimension The dimension of the embedding
* @return this builder
*/
public Builder withEmbeddingDimension(int newEmbeddingDimension) {
Assert.isTrue(newEmbeddingDimension >= 1 && newEmbeddingDimension <= 32768,
"Dimension has to be withing the boundaries 1 and 32768 (inclusively)");
this.embeddingDimension = newEmbeddingDimension;
return this;
}
/**
* Configures the ID field name. Default is {@value #DOC_ID_FIELD_NAME}.
* @param idFieldName The name for the ID field
* @return this builder
*/
public Builder withIDFieldName(String idFieldName) {
this.idFieldName = idFieldName;
return this;
}
/**
* Configures the boolean flag if the auto-id is used. Default is false.
* @param isAutoId boolean flag to indicate if the auto-id is enabled
* @return this builder
*/
public Builder withAutoId(boolean isAutoId) {
this.isAutoId = isAutoId;
return this;
}
/**
* Configures the content field name. Default is {@value #CONTENT_FIELD_NAME}.
* @param contentFieldName The name for the content field
* @return this builder
*/
public Builder withContentFieldName(String contentFieldName) {
this.contentFieldName = contentFieldName;
return this;
}
/**
* Configures the metadata field name. Default is
* {@value #METADATA_FIELD_NAME}.
* @param metadataFieldName The name for the metadata field
* @return this builder
*/
public Builder withMetadataFieldName(String metadataFieldName) {
this.metadataFieldName = metadataFieldName;
return this;
}
/**
* Configures the embedding field name. Default is
* {@value #EMBEDDING_FIELD_NAME}.
* @param embeddingFieldName The name for the embedding field
* @return this builder
*/
public Builder withEmbeddingFieldName(String embeddingFieldName) {
this.embeddingFieldName = embeddingFieldName;
return this;
}
/**
* {@return the immutable configuration}
*/
public MilvusVectorStoreConfig build() {
return new MilvusVectorStoreConfig(this);
}
}
}
}

View File

@@ -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.
@@ -165,35 +165,6 @@ public class MongoDBAtlasVectorStore extends AbstractObservationVectorStore impl
private final BatchingStrategy batchingStrategy;
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public MongoDBAtlasVectorStore(MongoTemplate mongoTemplate, EmbeddingModel embeddingModel,
boolean initializeSchema) {
this(mongoTemplate, embeddingModel, MongoDBVectorStoreConfig.defaultConfig(), initializeSchema);
}
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public MongoDBAtlasVectorStore(MongoTemplate mongoTemplate, EmbeddingModel embeddingModel,
MongoDBVectorStoreConfig config, boolean initializeSchema) {
this(mongoTemplate, embeddingModel, config, initializeSchema, ObservationRegistry.NOOP, null,
new TokenCountBatchingStrategy());
}
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public MongoDBAtlasVectorStore(MongoTemplate mongoTemplate, EmbeddingModel embeddingModel,
MongoDBVectorStoreConfig config, boolean initializeSchema, ObservationRegistry observationRegistry,
VectorStoreObservationConvention customObservationConvention, BatchingStrategy batchingStrategy) {
this(builder(mongoTemplate, embeddingModel).collectionName(config.collectionName)
.vectorIndexName(config.vectorIndexName)
.pathName(config.pathName)
.numCandidates(config.numCandidates)
.metadataFieldsToFilter(config.metadataFieldsToFilter)
.initializeSchema(initializeSchema)
.observationRegistry(observationRegistry)
.customObservationConvention(customObservationConvention)
.batchingStrategy(batchingStrategy));
}
protected MongoDBAtlasVectorStore(Builder builder) {
super(builder);
@@ -488,103 +459,6 @@ public class MongoDBAtlasVectorStore extends AbstractObservationVectorStore impl
}
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public static final class MongoDBVectorStoreConfig {
private final String collectionName;
private final String vectorIndexName;
private final String pathName;
private final List<String> metadataFieldsToFilter;
private final int numCandidates;
private MongoDBVectorStoreConfig(Builder builder) {
this.collectionName = builder.collectionName;
this.vectorIndexName = builder.vectorIndexName;
this.pathName = builder.pathName;
this.numCandidates = builder.numCandidates;
this.metadataFieldsToFilter = builder.metadataFieldsToFilter;
}
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public static Builder builder() {
return new Builder();
}
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public static MongoDBVectorStoreConfig defaultConfig() {
return builder().build();
}
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public static final class Builder {
private String collectionName = DEFAULT_VECTOR_COLLECTION_NAME;
private String vectorIndexName = DEFAULT_VECTOR_INDEX_NAME;
private String pathName = DEFAULT_PATH_NAME;
private int numCandidates = DEFAULT_NUM_CANDIDATES;
private List<String> metadataFieldsToFilter = Collections.emptyList();
private Builder() {
}
/**
* Configures the collection to use This must match the name of the collection
* for the Vector Search Index in Atlas
* @param collectionName
* @return this builder
*/
public Builder withCollectionName(String collectionName) {
Assert.notNull(collectionName, "Collection Name must not be empty");
this.collectionName = collectionName;
return this;
}
/**
* Configures the vector index name. This must match the name of the Vector
* Search Index Name in Atlas
* @param vectorIndexName
* @return this builder
*/
public Builder withVectorIndexName(String vectorIndexName) {
Assert.notNull(vectorIndexName, "Vector Index Name must not be empty");
this.vectorIndexName = vectorIndexName;
return this;
}
/**
* Configures the path name. This must match the name of the field indexed for
* the Vector Search Index in Atlas
* @param pathName
* @return this builder
*/
public Builder withPathName(String pathName) {
Assert.notNull(pathName, "Path Name must not be empty");
this.pathName = pathName;
return this;
}
public Builder withMetadataFieldsToFilter(List<String> metadataFieldsToFilter) {
Assert.notEmpty(metadataFieldsToFilter, "Fields list must not be empty");
this.metadataFieldsToFilter = metadataFieldsToFilter;
return this;
}
public MongoDBVectorStoreConfig build() {
return new MongoDBVectorStoreConfig(this);
}
}
}
/**
* The representation of {@link Document} along with its embedding.
*

View File

@@ -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.
@@ -180,32 +180,6 @@ public class Neo4jVectorStore extends AbstractObservationVectorStore implements
private final BatchingStrategy batchingStrategy;
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public Neo4jVectorStore(Driver driver, EmbeddingModel embeddingModel, Neo4jVectorStoreConfig config,
boolean initializeSchema) {
this(driver, embeddingModel, config, initializeSchema, ObservationRegistry.NOOP, null,
new TokenCountBatchingStrategy());
}
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public Neo4jVectorStore(Driver driver, EmbeddingModel embeddingModel, Neo4jVectorStoreConfig config,
boolean initializeSchema, ObservationRegistry observationRegistry,
VectorStoreObservationConvention customObservationConvention, BatchingStrategy batchingStrategy) {
this(builder(driver, embeddingModel).sessionConfig(config.sessionConfig)
.embeddingDimension(config.embeddingDimension)
.distanceType(config.distanceType)
.embeddingProperty(config.embeddingProperty)
.label(config.label)
.indexName(config.indexName)
.idProperty(config.idProperty)
.constraintName(config.constraintName)
.initializeSchema(initializeSchema)
.observationRegistry(observationRegistry)
.customObservationConvention(customObservationConvention)
.batchingStrategy(batchingStrategy));
}
protected Neo4jVectorStore(Builder builder) {
super(builder);
@@ -564,207 +538,4 @@ public class Neo4jVectorStore extends AbstractObservationVectorStore implements
}
/**
* Configuration for the Neo4j vector store.
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public static final class Neo4jVectorStoreConfig {
private final SessionConfig sessionConfig;
private final int embeddingDimension;
private final Neo4jDistanceType distanceType;
private final String embeddingProperty;
private final String label;
private final String indexName;
// needed for similarity search call
private final String indexNameNotSanitized;
private final String idProperty;
private final String constraintName;
private Neo4jVectorStoreConfig(Builder builder) {
this.sessionConfig = Optional.ofNullable(builder.databaseName)
.filter(Predicate.not(String::isBlank))
.map(SessionConfig::forDatabase)
.orElseGet(SessionConfig::defaultConfig);
this.embeddingDimension = builder.embeddingDimension;
this.distanceType = builder.distanceType;
this.embeddingProperty = SchemaNames.sanitize(builder.embeddingProperty).orElseThrow();
this.label = SchemaNames.sanitize(builder.label).orElseThrow();
this.indexNameNotSanitized = builder.indexName;
this.indexName = SchemaNames.sanitize(builder.indexName, true).orElseThrow();
this.constraintName = SchemaNames.sanitize(builder.constraintName).orElseThrow();
this.idProperty = SchemaNames.sanitize(builder.idProperty).orElseThrow();
}
/**
* Start building a new configuration.
* @return The entry point for creating a new configuration.
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public static Builder builder() {
return new Builder();
}
/**
* {@return the default config}
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public static Neo4jVectorStoreConfig defaultConfig() {
return builder().build();
}
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public static final class Builder {
private String databaseName;
private int embeddingDimension = DEFAULT_EMBEDDING_DIMENSION;
private Neo4jDistanceType distanceType = Neo4jDistanceType.COSINE;
private String label = DEFAULT_LABEL;
private String embeddingProperty = DEFAULT_EMBEDDING_PROPERTY;
private String indexName = DEFAULT_INDEX_NAME;
private String idProperty = DEFAULT_ID_PROPERTY;
private String constraintName = DEFAULT_CONSTRAINT_NAME;
private Builder() {
}
/**
* Configures the Neo4j database name to use. Leave {@literal null} or blank
* to use the default database.
* @param databaseName the database name to use
* @return this builder
*/
public Builder withDatabaseName(String databaseName) {
this.databaseName = databaseName;
return this;
}
/**
* Configures the size of the embedding. Defaults to {@literal 1536}, inline
* with OpenAIs embeddings.
* @param newEmbeddingDimension The dimension of the embedding
* @return this builder
*/
public Builder withEmbeddingDimension(int newEmbeddingDimension) {
Assert.isTrue(newEmbeddingDimension >= 1, "Dimension has to be positive.");
this.embeddingDimension = newEmbeddingDimension;
return this;
}
/**
* Configures the distance type to store in the index and to use in queries.
* @param newDistanceType The distance type, must not be {@literal null}
* @return this builder
*/
public Builder withDistanceType(Neo4jDistanceType newDistanceType) {
Assert.notNull(newDistanceType, "Distance type may not be null");
this.distanceType = newDistanceType;
return this;
}
/**
* Configures the node label to use for storing documents. Defaults to
* {@literal Document}.
* @param newLabel The label used on the nodes representing the document
* @return this builder
*/
public Builder withLabel(String newLabel) {
Assert.hasText(newLabel, "Content label may not be null or blank");
this.label = newLabel;
return this;
}
/**
* Configures the property of the node to use for storing embedding. Defaults
* to {@literal embedding}.
* @param newEmbeddingProperty The property of the nodes for storing the
* embedding
* @return this builder
*/
public Builder withEmbeddingProperty(String newEmbeddingProperty) {
Assert.hasText(newEmbeddingProperty, "Embedding property may not be null or blank");
this.embeddingProperty = newEmbeddingProperty;
return this;
}
/**
* Configures the vector index to be used. Defaults to
* {@literal spring-ai-document-index}.
* @param newIndexName The name of the index to be used for storing and
* searching data.
* @return this builder
*/
public Builder withIndexName(String newIndexName) {
Assert.hasText(newIndexName, "Index name may not be null or blank");
this.indexName = newIndexName;
return this;
}
/**
* Configures the id property to be used. Defaults to {@literal id}.
* @param newIdProperty The name of the id property of the {@link Document}
* entity
* @return this builder
*/
public Builder withIdProperty(String newIdProperty) {
Assert.hasText(newIdProperty, "Id property may not be null or blank");
this.idProperty = newIdProperty;
return this;
}
/**
* Configures the constraint name to be used. Defaults to
* {@literal Document_unique_idx}.
* @param newConstraintName The name of the unique constraint for the id
* property.
* @return this builder
*/
public Builder withConstraintName(String newConstraintName) {
Assert.hasText(newConstraintName, "Constraint name may not be null or blank");
this.constraintName = newConstraintName;
return this;
}
/**
* {@return the immutable configuration}
*/
public Neo4jVectorStoreConfig build() {
return new Neo4jVectorStoreConfig(this);
}
}
}
}

View File

@@ -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.
@@ -170,78 +170,6 @@ public class OpenSearchVectorStore extends AbstractObservationVectorStore implem
private String similarityFunction;
/**
* Creates a new OpenSearchVectorStore with default mapping and collection name.
* @deprecated Use {@link #builder(OpenSearchClient, EmbeddingModel)} ()} instead
* @param openSearchClient The OpenSearch client
* @param embeddingModel The embedding model to use
* @param initializeSchema Whether to initialize the schema
* @since 1.0.0
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public OpenSearchVectorStore(OpenSearchClient openSearchClient, EmbeddingModel embeddingModel,
boolean initializeSchema) {
this(openSearchClient, embeddingModel, DEFAULT_MAPPING_EMBEDDING_TYPE_KNN_VECTOR_DIMENSION, initializeSchema);
}
/**
* Creates a new OpenSearchVectorStore with custom mapping.
* @deprecated Use {@link #builder(OpenSearchClient, EmbeddingModel)} ()} instead
* @param openSearchClient The OpenSearch client
* @param embeddingModel The embedding model to use
* @param mappingJson The JSON mapping for the index
* @param initializeSchema Whether to initialize the schema
* @since 1.0.0
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public OpenSearchVectorStore(OpenSearchClient openSearchClient, EmbeddingModel embeddingModel, String mappingJson,
boolean initializeSchema) {
this(DEFAULT_INDEX_NAME, openSearchClient, embeddingModel, mappingJson, initializeSchema);
}
/**
* Creates a new OpenSearchVectorStore with custom index name and mapping.
* @deprecated Use {@link #builder(OpenSearchClient, EmbeddingModel)} ()} instead
* @param index The name of the index
* @param openSearchClient The OpenSearch client
* @param embeddingModel The embedding model to use
* @param mappingJson The JSON mapping for the index
* @param initializeSchema Whether to initialize the schema
* @since 1.0.0
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public OpenSearchVectorStore(String index, OpenSearchClient openSearchClient, EmbeddingModel embeddingModel,
String mappingJson, boolean initializeSchema) {
this(index, openSearchClient, embeddingModel, mappingJson, initializeSchema, ObservationRegistry.NOOP, null,
new TokenCountBatchingStrategy());
}
/**
* Creates a new OpenSearchVectorStore with all configuration options.
* @deprecated Use {@link #builder(OpenSearchClient, EmbeddingModel)} ()} instead
* @param index The name of the index
* @param openSearchClient The OpenSearch client
* @param embeddingModel The embedding model to use
* @param mappingJson The JSON mapping for the index
* @param initializeSchema Whether to initialize the schema
* @param observationRegistry The observation registry for metrics
* @param customObservationConvention Custom observation convention
* @param batchingStrategy The strategy for batching operations
* @since 1.0.0
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public OpenSearchVectorStore(String index, OpenSearchClient openSearchClient, EmbeddingModel embeddingModel,
String mappingJson, boolean initializeSchema, ObservationRegistry observationRegistry,
VectorStoreObservationConvention customObservationConvention, BatchingStrategy batchingStrategy) {
this(builder(openSearchClient, embeddingModel).index(index)
.mappingJson(mappingJson)
.initializeSchema(initializeSchema)
.observationRegistry(observationRegistry)
.customObservationConvention(customObservationConvention)
.batchingStrategy(batchingStrategy));
}
/**
* Creates a new OpenSearchVectorStore using the builder pattern.
* @param builder The configured builder instance

View File

@@ -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.
@@ -146,97 +146,6 @@ public class OracleVectorStore extends AbstractObservationVectorStore implements
private final ByteArrayOutputStream out = new ByteArrayOutputStream();
/**
* Creates a new OracleVectorStore with default configuration.
* @param jdbcTemplate the JDBC template to use
* @param embeddingModel the embedding model to use
* @deprecated Since 1.0.0-M5, use {@link #builder(JdbcTemplate, EmbeddingModel)} ()}
* instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public OracleVectorStore(JdbcTemplate jdbcTemplate, EmbeddingModel embeddingModel) {
this(jdbcTemplate, embeddingModel, DEFAULT_TABLE_NAME, DEFAULT_INDEX_TYPE, DEFAULT_DISTANCE_TYPE,
DEFAULT_DIMENSIONS, DEFAULT_SEARCH_ACCURACY, false, false, false);
}
/**
* Creates a new OracleVectorStore with schema initialization option.
* @param jdbcTemplate the JDBC template to use
* @param embeddingModel the embedding model to use
* @param initializeSchema whether to initialize the schema
* @deprecated Since 1.0.0-M5, use {@link #builder(JdbcTemplate, EmbeddingModel)} ()}
* instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public OracleVectorStore(JdbcTemplate jdbcTemplate, EmbeddingModel embeddingModel, boolean initializeSchema) {
this(jdbcTemplate, embeddingModel, DEFAULT_TABLE_NAME, DEFAULT_INDEX_TYPE, DEFAULT_DISTANCE_TYPE,
DEFAULT_DIMENSIONS, DEFAULT_SEARCH_ACCURACY, initializeSchema, false, false);
}
/**
* Creates a new OracleVectorStore with full configuration options.
* @param jdbcTemplate the JDBC template to use
* @param embeddingModel the embedding model to use
* @param tableName the table name for vector storage
* @param indexType the type of vector index
* @param distanceType the distance type for similarity calculations
* @param dimensions the number of vector dimensions
* @param searchAccuracy the search accuracy parameter
* @param initializeSchema whether to initialize the schema
* @param removeExistingVectorStoreTable whether to remove existing vector store table
* @param forcedNormalization whether to force vector normalization
* @deprecated Since 1.0.0-M5, use {@link #builder(JdbcTemplate, EmbeddingModel)} ()}
* instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public OracleVectorStore(JdbcTemplate jdbcTemplate, EmbeddingModel embeddingModel, String tableName,
OracleVectorStoreIndexType indexType, OracleVectorStoreDistanceType distanceType, int dimensions,
int searchAccuracy, boolean initializeSchema, boolean removeExistingVectorStoreTable,
boolean forcedNormalization) {
this(jdbcTemplate, embeddingModel, tableName, indexType, distanceType, dimensions, searchAccuracy,
initializeSchema, removeExistingVectorStoreTable, forcedNormalization, ObservationRegistry.NOOP, null,
new TokenCountBatchingStrategy());
}
/**
* Creates a new OracleVectorStore with full configuration including observation
* options.
* @param jdbcTemplate the JDBC template to use
* @param embeddingModel the embedding model to use
* @param tableName the table name for vector storage
* @param indexType the type of vector index
* @param distanceType the distance type for similarity calculations
* @param dimensions the number of vector dimensions
* @param searchAccuracy the search accuracy parameter
* @param initializeSchema whether to initialize the schema
* @param removeExistingVectorStoreTable whether to remove existing vector store table
* @param forcedNormalization whether to force vector normalization
* @param observationRegistry the observation registry
* @param customObservationConvention the custom observation convention
* @param batchingStrategy the batching strategy
* @deprecated Since 1.0.0-M5, use {@link #builder(JdbcTemplate, EmbeddingModel)} ()}
* instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public OracleVectorStore(JdbcTemplate jdbcTemplate, EmbeddingModel embeddingModel, String tableName,
OracleVectorStoreIndexType indexType, OracleVectorStoreDistanceType distanceType, int dimensions,
int searchAccuracy, boolean initializeSchema, boolean removeExistingVectorStoreTable,
boolean forcedNormalization, ObservationRegistry observationRegistry,
VectorStoreObservationConvention customObservationConvention, BatchingStrategy batchingStrategy) {
this(builder(jdbcTemplate, embeddingModel).tableName(tableName)
.indexType(indexType)
.distanceType(distanceType)
.dimensions(dimensions)
.searchAccuracy(searchAccuracy)
.initializeSchema(initializeSchema)
.removeExistingVectorStoreTable(removeExistingVectorStoreTable)
.forcedNormalization(forcedNormalization)
.observationRegistry(observationRegistry)
.customObservationConvention(customObservationConvention)
.batchingStrategy(batchingStrategy));
}
/**
* Protected constructor that accepts a builder instance. This is the preferred way to
* create new OracleVectorStore instances.

View File

@@ -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.
@@ -210,41 +210,6 @@ public class PgVectorStore extends AbstractObservationVectorStore implements Ini
private final int maxDocumentBatchSize;
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public PgVectorStore(JdbcTemplate jdbcTemplate, EmbeddingModel embeddingModel) {
this(jdbcTemplate, embeddingModel, INVALID_EMBEDDING_DIMENSION, PgDistanceType.COSINE_DISTANCE, false,
PgIndexType.NONE, false);
}
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public PgVectorStore(JdbcTemplate jdbcTemplate, EmbeddingModel embeddingModel, int dimensions) {
this(jdbcTemplate, embeddingModel, dimensions, PgDistanceType.COSINE_DISTANCE, false, PgIndexType.NONE, false);
}
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public PgVectorStore(JdbcTemplate jdbcTemplate, EmbeddingModel embeddingModel, int dimensions,
PgDistanceType distanceType, boolean removeExistingVectorStoreTable, PgIndexType createIndexMethod,
boolean initializeSchema) {
this(DEFAULT_TABLE_NAME, jdbcTemplate, embeddingModel, dimensions, distanceType, removeExistingVectorStoreTable,
createIndexMethod, initializeSchema);
}
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public PgVectorStore(String vectorTableName, JdbcTemplate jdbcTemplate, EmbeddingModel embeddingModel,
int dimensions, PgDistanceType distanceType, boolean removeExistingVectorStoreTable,
PgIndexType createIndexMethod, boolean initializeSchema) {
this(builder(jdbcTemplate, embeddingModel).schemaName(DEFAULT_SCHEMA_NAME)
.vectorTableName(vectorTableName)
.vectorTableValidationsEnabled(DEFAULT_SCHEMA_VALIDATION)
.dimensions(dimensions)
.distanceType(distanceType)
.removeExistingVectorStoreTable(removeExistingVectorStoreTable)
.indexType(createIndexMethod)
.initializeSchema(initializeSchema));
}
/**
* @param builder {@link VectorStore.Builder} for pg vector store
*/
@@ -703,121 +668,4 @@ public class PgVectorStore extends AbstractObservationVectorStore implements Ini
}
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public static class Builder {
private final JdbcTemplate jdbcTemplate;
private final EmbeddingModel embeddingModel;
private String schemaName = PgVectorStore.DEFAULT_SCHEMA_NAME;
private String vectorTableName;
private boolean vectorTableValidationsEnabled = PgVectorStore.DEFAULT_SCHEMA_VALIDATION;
private int dimensions = PgVectorStore.INVALID_EMBEDDING_DIMENSION;
private PgDistanceType distanceType = PgDistanceType.COSINE_DISTANCE;
private boolean removeExistingVectorStoreTable = false;
private PgIndexType indexType = PgIndexType.HNSW;
private boolean initializeSchema;
private ObservationRegistry observationRegistry = ObservationRegistry.NOOP;
private BatchingStrategy batchingStrategy = new TokenCountBatchingStrategy();
private int maxDocumentBatchSize = MAX_DOCUMENT_BATCH_SIZE;
@Nullable
private VectorStoreObservationConvention searchObservationConvention;
public Builder(JdbcTemplate jdbcTemplate, EmbeddingModel embeddingModel) {
if (jdbcTemplate == null || embeddingModel == null) {
throw new IllegalArgumentException("JdbcTemplate and EmbeddingModel must not be null");
}
this.jdbcTemplate = jdbcTemplate;
this.embeddingModel = embeddingModel;
}
public Builder withSchemaName(String schemaName) {
this.schemaName = schemaName;
return this;
}
public Builder withVectorTableName(String vectorTableName) {
this.vectorTableName = vectorTableName;
return this;
}
public Builder withVectorTableValidationsEnabled(boolean vectorTableValidationsEnabled) {
this.vectorTableValidationsEnabled = vectorTableValidationsEnabled;
return this;
}
public Builder withDimensions(int dimensions) {
this.dimensions = dimensions;
return this;
}
public Builder withDistanceType(PgDistanceType distanceType) {
this.distanceType = distanceType;
return this;
}
public Builder withRemoveExistingVectorStoreTable(boolean removeExistingVectorStoreTable) {
this.removeExistingVectorStoreTable = removeExistingVectorStoreTable;
return this;
}
public Builder withIndexType(PgIndexType indexType) {
this.indexType = indexType;
return this;
}
public Builder withInitializeSchema(boolean initializeSchema) {
this.initializeSchema = initializeSchema;
return this;
}
public Builder withObservationRegistry(ObservationRegistry observationRegistry) {
this.observationRegistry = observationRegistry;
return this;
}
public Builder withSearchObservationConvention(VectorStoreObservationConvention customObservationConvention) {
this.searchObservationConvention = customObservationConvention;
return this;
}
public Builder withBatchingStrategy(BatchingStrategy batchingStrategy) {
this.batchingStrategy = batchingStrategy;
return this;
}
public Builder withMaxDocumentBatchSize(int maxDocumentBatchSize) {
this.maxDocumentBatchSize = maxDocumentBatchSize;
return this;
}
public PgVectorStore build() {
return PgVectorStore.builder(this.jdbcTemplate, this.embeddingModel)
.schemaName(this.schemaName)
.vectorTableName(this.vectorTableName)
.vectorTableValidationsEnabled(this.vectorTableValidationsEnabled)
.dimensions(this.dimensions)
.distanceType(this.distanceType)
.removeExistingVectorStoreTable(this.removeExistingVectorStoreTable)
.indexType(this.indexType)
.initializeSchema(this.initializeSchema)
.batchingStrategy(this.batchingStrategy)
.maxDocumentBatchSize(this.maxDocumentBatchSize)
.build();
}
}
}

View File

@@ -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.
@@ -86,43 +86,6 @@ public class PineconeVectorStore extends AbstractObservationVectorStore {
private final BatchingStrategy batchingStrategy;
/**
* Constructs a new PineconeVectorStore.
* @deprecated Use {@link #builder(EmbeddingModel, String, String, String, String)}
* ()} instead
* @param config The configuration for the store
* @param embeddingModel The client for embedding operations
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public PineconeVectorStore(PineconeVectorStoreConfig config, EmbeddingModel embeddingModel) {
this(config, embeddingModel, ObservationRegistry.NOOP, null, new TokenCountBatchingStrategy());
}
/**
* Constructs a new PineconeVectorStore.
* @deprecated Use {@link #builder(EmbeddingModel, String, String, String, String)}
* ()} instead
* @param config The configuration for the store
* @param embeddingModel The client for embedding operations
* @param observationRegistry The registry for observations
* @param customObservationConvention The custom observation convention
* @param batchingStrategy The strategy for batching operations
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public PineconeVectorStore(PineconeVectorStoreConfig config, EmbeddingModel embeddingModel,
ObservationRegistry observationRegistry, VectorStoreObservationConvention customObservationConvention,
BatchingStrategy batchingStrategy) {
this(builder(embeddingModel, config.clientConfig.getApiKey(), config.clientConfig.getProjectName(),
config.clientConfig.getEnvironment(), config.connectionConfig.getIndexName())
.namespace(config.namespace)
.contentFieldName(config.contentFieldName)
.distanceMetadataFieldName(config.distanceMetadataFieldName)
.serverSideTimeout(Duration.ofSeconds(config.clientConfig.getServerSideTimeoutSec()))
.observationRegistry(observationRegistry)
.customObservationConvention(customObservationConvention)
.batchingStrategy(batchingStrategy));
}
/**
* Creates a new PineconeVectorStore using the builder pattern.
* @param builder The configured builder instance
@@ -439,236 +402,4 @@ public class PineconeVectorStore extends AbstractObservationVectorStore {
}
/**
* Configuration for PineconeVectorStore.
*
* @deprecated Use
* {@link PineconeVectorStore#builder(EmbeddingModel, String, String, String, String)}
* ()} instead. This class will be removed in a future release as part of the
* migration to the builder pattern.
* @since 1.0.0
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public static final class PineconeVectorStoreConfig {
// The free tier (gcp-starter) doesn't support Namespaces.
// Leave the namespace empty (e.g. "") for the free tier.
private final String namespace;
private final String contentFieldName;
// TODO: Why is this field configurable? Can we remove this after standardizing
// the key?
private final String distanceMetadataFieldName;
private final PineconeConnectionConfig connectionConfig;
private final PineconeClientConfig clientConfig;
/**
* Constructor using the builder.
* @param builder The configuration builder
* @deprecated Use
* {@link PineconeVectorStore#builder(EmbeddingModel, String, String, String, String)}
* ()} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public PineconeVectorStoreConfig(Builder builder) {
this.namespace = builder.namespace;
this.contentFieldName = builder.contentFieldName;
this.distanceMetadataFieldName = builder.distanceMetadataFieldName;
this.connectionConfig = new PineconeConnectionConfig().withIndexName(builder.indexName);
this.clientConfig = new PineconeClientConfig().withApiKey(builder.apiKey)
.withEnvironment(builder.environment)
.withProjectName(builder.projectId)
.withServerSideTimeoutSec((int) builder.serverSideTimeout.toSeconds());
}
/**
* Start building a new configuration.
* @return The entry point for creating a new configuration
* @deprecated Use
* {@link PineconeVectorStore#builder(EmbeddingModel, String, String, String, String)}
* ()} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public static Builder builder() {
return new Builder();
}
/**
* {@return the default config}
* @deprecated Use
* {@link PineconeVectorStore#builder(EmbeddingModel, String, String, String, String)}
* ()} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public static PineconeVectorStoreConfig defaultConfig() {
return builder().build();
}
/**
* Builder for PineconeVectorStoreConfig.
*
* @deprecated Use
* {@link PineconeVectorStore#builder(EmbeddingModel, String, String, String, String)}
* ()} instead. This class will be removed in a future release as part of the
* migration to the builder pattern.
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public static final class Builder {
private String apiKey;
private String projectId;
private String environment;
private String indexName;
// The free-tier (gcp-starter) doesn't support Namespaces!
private String namespace = "";
private String contentFieldName = CONTENT_FIELD_NAME;
private String distanceMetadataFieldName = DocumentMetadata.DISTANCE.value();
/**
* Optional server-side timeout in seconds for all operations. Default: 20
* seconds.
*/
private Duration serverSideTimeout = Duration.ofSeconds(20);
private Builder() {
}
/**
* Pinecone api key.
* @param apiKey key to use
* @return this builder
* @deprecated Use
* {@link PineconeVectorStore#builder(EmbeddingModel, String, String, String, String)}
* ()} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public Builder withApiKey(String apiKey) {
this.apiKey = apiKey;
return this;
}
/**
* Pinecone project id.
* @param projectId Project id to use
* @return this builder
* @deprecated Use
* {@link PineconeVectorStore#builder(EmbeddingModel, String, String, String, String)}
* ()} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public Builder withProjectId(String projectId) {
this.projectId = projectId;
return this;
}
/**
* Pinecone environment name.
* @param environment Environment name (e.g. gcp-starter)
* @return this builder
* @deprecated Use
* {@link PineconeVectorStore#builder(EmbeddingModel, String, String, String, String)}
* ()} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public Builder withEnvironment(String environment) {
this.environment = environment;
return this;
}
/**
* Pinecone index name.
* @param indexName Pinecone index name to use
* @return this builder
* @deprecated Use
* {@link PineconeVectorStore#builder(EmbeddingModel, String, String, String, String)}
* ()} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public Builder withIndexName(String indexName) {
this.indexName = indexName;
return this;
}
/**
* Pinecone Namespace. The free-tier (gcp-starter) doesn't support Namespaces.
* For free-tier leave the namespace empty.
* @param namespace Pinecone namespace to use
* @return this builder
* @deprecated Use
* {@link PineconeVectorStore#builder(EmbeddingModel, String, String, String, String)}
* ()} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public Builder withNamespace(String namespace) {
this.namespace = namespace;
return this;
}
/**
* Content field name.
* @param contentFieldName content field name to use
* @return this builder
* @deprecated Use
* {@link PineconeVectorStore#builder(EmbeddingModel, String, String, String, String)}
* ()} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public Builder withContentFieldName(String contentFieldName) {
this.contentFieldName = contentFieldName;
return this;
}
/**
* Distance metadata field name.
* @param distanceMetadataFieldName distance metadata field name to use
* @return this builder
* @deprecated Use
* {@link PineconeVectorStore#builder(EmbeddingModel, String, String, String, String)}
* ()} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public Builder withDistanceMetadataFieldName(String distanceMetadataFieldName) {
this.distanceMetadataFieldName = distanceMetadataFieldName;
return this;
}
/**
* Pinecone server side timeout.
* @param serverSideTimeout server timeout to use
* @return this builder
* @deprecated Use
* {@link PineconeVectorStore#builder(EmbeddingModel, String, String, String, String)}
* ()} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public Builder withServerSideTimeout(Duration serverSideTimeout) {
this.serverSideTimeout = serverSideTimeout;
return this;
}
/**
* {@return the immutable configuration}
* @deprecated Use
* {@link PineconeVectorStore#builder(EmbeddingModel, String, String, String, String)}
* ()} instead
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public PineconeVectorStoreConfig build() {
return new PineconeVectorStoreConfig(this);
}
}
}
}

View File

@@ -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.
@@ -235,30 +235,6 @@ public class RedisVectorStore extends AbstractObservationVectorStore implements
private final FilterExpressionConverter filterExpressionConverter;
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public RedisVectorStore(RedisVectorStoreConfig config, EmbeddingModel embeddingModel, JedisPooled jedis,
boolean initializeSchema) {
this(config, embeddingModel, jedis, initializeSchema, ObservationRegistry.NOOP, null,
new TokenCountBatchingStrategy());
}
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public RedisVectorStore(RedisVectorStoreConfig config, EmbeddingModel embeddingModel, JedisPooled jedis,
boolean initializeSchema, ObservationRegistry observationRegistry,
VectorStoreObservationConvention customObservationConvention, BatchingStrategy batchingStrategy) {
this(builder(jedis, embeddingModel).indexName(config.indexName)
.prefix(config.prefix)
.contentFieldName(config.contentFieldName)
.embeddingFieldName(config.embeddingFieldName)
.vectorAlgorithm(config.vectorAlgorithm)
.metadataFields(config.metadataFields)
.initializeSchema(initializeSchema)
.observationRegistry(observationRegistry)
.customObservationConvention(customObservationConvention)
.batchingStrategy(batchingStrategy));
}
protected RedisVectorStore(Builder builder) {
super(builder);
@@ -620,141 +596,4 @@ public class RedisVectorStore extends AbstractObservationVectorStore implements
}
/**
* Configuration for the Redis vector store.
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public static final class RedisVectorStoreConfig {
private final String indexName;
private final String prefix;
private final String contentFieldName;
private final String embeddingFieldName;
private final Algorithm vectorAlgorithm;
private final List<MetadataField> metadataFields;
private RedisVectorStoreConfig() {
this(builder());
}
private RedisVectorStoreConfig(Builder builder) {
this.indexName = builder.indexName;
this.prefix = builder.prefix;
this.contentFieldName = builder.contentFieldName;
this.embeddingFieldName = builder.embeddingFieldName;
this.vectorAlgorithm = builder.vectorAlgorithm;
this.metadataFields = builder.metadataFields;
}
/**
* Start building a new configuration.
* @return The entry point for creating a new configuration.
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public static Builder builder() {
return new Builder();
}
/**
* {@return the default config}
*/
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public static RedisVectorStoreConfig defaultConfig() {
return builder().build();
}
@Deprecated(since = "1.0.0-M5", forRemoval = true)
public static final class Builder {
private String indexName = DEFAULT_INDEX_NAME;
private String prefix = DEFAULT_PREFIX;
private String contentFieldName = DEFAULT_CONTENT_FIELD_NAME;
private String embeddingFieldName = DEFAULT_EMBEDDING_FIELD_NAME;
private Algorithm vectorAlgorithm = DEFAULT_VECTOR_ALGORITHM;
private List<MetadataField> metadataFields = new ArrayList<>();
private Builder() {
}
/**
* Configures the Redis index name to use.
* @param name the index name to use
* @return this builder
*/
public Builder withIndexName(String name) {
this.indexName = name;
return this;
}
/**
* Configures the Redis key prefix to use (default: "embedding:").
* @param prefix the prefix to use
* @return this builder
*/
public Builder withPrefix(String prefix) {
this.prefix = prefix;
return this;
}
/**
* Configures the Redis content field name to use.
* @param name the content field name to use
* @return this builder
*/
public Builder withContentFieldName(String name) {
this.contentFieldName = name;
return this;
}
/**
* Configures the Redis embedding field name to use.
* @param name the embedding field name to use
* @return this builder
*/
public Builder withEmbeddingFieldName(String name) {
this.embeddingFieldName = name;
return this;
}
/**
* Configures the Redis vector algorithm to use.
* @param algorithm the vector algorithm to use
* @return this builder
*/
public Builder withVectorAlgorithm(Algorithm algorithm) {
this.vectorAlgorithm = algorithm;
return this;
}
public Builder withMetadataFields(MetadataField... fields) {
return withMetadataFields(Arrays.asList(fields));
}
public Builder withMetadataFields(List<MetadataField> fields) {
this.metadataFields = fields;
return this;
}
/**
* {@return the immutable configuration}
*/
public RedisVectorStoreConfig build() {
return new RedisVectorStoreConfig(this);
}
}
}
}

View File

@@ -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.
@@ -102,9 +102,6 @@ public class TypesenseVectorStore extends AbstractObservationVectorStore impleme
private final Client client;
@Deprecated(forRemoval = true, since = "1.0.0-M5")
private final TypesenseVectorStoreConfig config;
private final boolean initializeSchema;
private final BatchingStrategy batchingStrategy;
@@ -113,40 +110,6 @@ public class TypesenseVectorStore extends AbstractObservationVectorStore impleme
private final int embeddingDimension;
/**
* @deprecated Use {@link #builder(Client, EmbeddingModel)} ()} instead
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public TypesenseVectorStore(Client client, EmbeddingModel embeddingModel) {
this(client, embeddingModel, TypesenseVectorStoreConfig.defaultConfig(), false);
}
/**
* @deprecated Use {@link #builder(Client, EmbeddingModel)} ()} instead
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public TypesenseVectorStore(Client client, EmbeddingModel embeddingModel, TypesenseVectorStoreConfig config,
boolean initializeSchema) {
this(client, embeddingModel, config, initializeSchema, ObservationRegistry.NOOP, null,
new TokenCountBatchingStrategy());
}
/**
* @deprecated Use {@link #builder(Client, EmbeddingModel)} ()} instead
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public TypesenseVectorStore(Client client, EmbeddingModel embeddingModel, TypesenseVectorStoreConfig config,
boolean initializeSchema, ObservationRegistry observationRegistry,
VectorStoreObservationConvention customObservationConvention, BatchingStrategy batchingStrategy) {
this(builder(client, embeddingModel).collectionName(config.collectionName)
.embeddingDimension(config.embeddingDimension)
.initializeSchema(initializeSchema)
.observationRegistry(observationRegistry)
.customObservationConvention(customObservationConvention)
.batchingStrategy(batchingStrategy));
}
/**
* Protected constructor for creating a TypesenseVectorStore instance using the
* builder pattern. This constructor initializes the vector store with the configured
@@ -167,7 +130,6 @@ public class TypesenseVectorStore extends AbstractObservationVectorStore impleme
this.batchingStrategy = builder.batchingStrategy;
this.collectionName = builder.collectionName;
this.embeddingDimension = builder.embeddingDimension;
this.config = null;
}
/**
@@ -471,86 +433,4 @@ public class TypesenseVectorStore extends AbstractObservationVectorStore impleme
}
/**
* @deprecated Use {@link TypesenseVectorStore#builder(Client, EmbeddingModel)} ()}
* instead
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public static class TypesenseVectorStoreConfig {
private final String collectionName;
private final int embeddingDimension;
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public TypesenseVectorStoreConfig(String collectionName, int embeddingDimension) {
this.collectionName = collectionName;
this.embeddingDimension = embeddingDimension;
}
private TypesenseVectorStoreConfig(Builder builder) {
this.collectionName = builder.collectionName;
this.embeddingDimension = builder.embeddingDimension;
}
/**
* {@return the default config}
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public static TypesenseVectorStoreConfig defaultConfig() {
return builder().build();
}
/**
* Start building a new configuration.
* @return The entry point for creating a new configuration.
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public static Builder builder() {
return new Builder();
}
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public static class Builder {
private String collectionName;
private int embeddingDimension;
/**
* Set the collection name.
* @param collectionName The collection name.
* @return The builder.
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public Builder withCollectionName(String collectionName) {
this.collectionName = collectionName;
return this;
}
/**
* Set the embedding dimension.
* @param embeddingDimension The embedding dimension.
* @return The builder.
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public Builder withEmbeddingDimension(int embeddingDimension) {
this.embeddingDimension = embeddingDimension;
return this;
}
/**
* Build the configuration.
* @return The configuration.
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public TypesenseVectorStoreConfig build() {
return new TypesenseVectorStoreConfig(this);
}
}
}
}

View File

@@ -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.
@@ -145,48 +145,6 @@ public class WeaviateVectorStore extends AbstractObservationVectorStore {
*/
private final ObjectMapper objectMapper = new ObjectMapper();
/**
* Constructs a new WeaviateVectorStore with default settings.
* @param vectorStoreConfig The configuration for the store
* @param embeddingModel The client for embedding operations
* @param weaviateClient The client for Weaviate operations
* @deprecated Use {@link #builder(WeaviateClient, EmbeddingModel)} ()} instead to
* create instances of WeaviateVectorStore. This constructor will be removed in a
* future release.
* @see #builder(WeaviateClient, EmbeddingModel) ()
* @since 1.0.0
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public WeaviateVectorStore(WeaviateVectorStoreConfig vectorStoreConfig, EmbeddingModel embeddingModel,
WeaviateClient weaviateClient) {
this(vectorStoreConfig, embeddingModel, weaviateClient, ObservationRegistry.NOOP, null,
new TokenCountBatchingStrategy());
}
/**
* Constructs a new WeaviateVectorStore with custom settings.
* @param vectorStoreConfig The configuration for the store
* @param embeddingModel The client for embedding operations
* @param weaviateClient The client for Weaviate operations
* @param observationRegistry The registry for observations
* @param customObservationConvention The custom observation convention
* @param batchingStrategy The strategy for batching operations
* @deprecated Use {@link #builder(WeaviateClient, EmbeddingModel)} ()} instead to
* create instances of WeaviateVectorStore. This constructor will be removed in a
* future release.
* @see #builder(WeaviateClient, EmbeddingModel) ()
* @since 1.0.0
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public WeaviateVectorStore(WeaviateVectorStoreConfig vectorStoreConfig, EmbeddingModel embeddingModel,
WeaviateClient weaviateClient, ObservationRegistry observationRegistry,
VectorStoreObservationConvention customObservationConvention, BatchingStrategy batchingStrategy) {
this(builder(weaviateClient, embeddingModel).observationRegistry(observationRegistry)
.customObservationConvention(customObservationConvention)
.batchingStrategy(batchingStrategy));
}
/**
* Protected constructor for creating a WeaviateVectorStore instance using the builder
* pattern. This constructor initializes the vector store with the configured settings
@@ -617,289 +575,4 @@ public class WeaviateVectorStore extends AbstractObservationVectorStore {
}
/**
* Configuration class for WeaviateVectorStore.
*
* @deprecated Use {@link WeaviateVectorStore#builder(WeaviateClient, EmbeddingModel)}
* ()} instead to configure and create instances of WeaviateVectorStore. This class
* will be removed in a future release. Example migration: <pre>{@code
* // Old approach:
* WeaviateVectorStoreConfig config = WeaviateVectorStoreConfig.builder()
* .withObjectClass("CustomClass")
* .withConsistencyLevel(ConsistentLevel.QUORUM)
* .build();
*
* // New approach:
* WeaviateVectorStore store = WeaviateVectorStore.builder()
* .objectClass("CustomClass")
* .consistencyLevel(ConsistentLevel.QUORUM)
* .build();
* }</pre>
* @see WeaviateVectorStore#builder(WeaviateClient, EmbeddingModel) ()
* @since 1.0.0
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public static final class WeaviateVectorStoreConfig {
private final String weaviateObjectClass;
private final ConsistentLevel consistencyLevel;
/**
* Known metadata fields to add as a fields to the Weaviate schema. You can add
* arbitrary metadata with your documents but only the metadata fields listed here
* can be used in the expression filters.
*/
private final List<MetadataField> filterMetadataFields;
private final Map<String, String> headers;
/**
* Constructor using the builder.
* @param builder The configuration builder
* @deprecated Use
* {@link WeaviateVectorStore#builder(WeaviateClient, EmbeddingModel)} ()} instead
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public WeaviateVectorStoreConfig(Builder builder) {
this.weaviateObjectClass = builder.objectClass;
this.consistencyLevel = builder.consistencyLevel;
this.filterMetadataFields = builder.filterMetadataFields;
this.headers = builder.headers;
}
/**
* Start building a new configuration.
* @return The entry point for creating a new configuration
* @deprecated Use
* {@link WeaviateVectorStore#builder(WeaviateClient, EmbeddingModel)} ()} instead
* to configure and create instances of WeaviateVectorStore
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public static Builder builder() {
return new Builder();
}
/**
* Returns the default configuration.
* @return the default configuration
* @deprecated Use
* {@link WeaviateVectorStore#builder(WeaviateClient, EmbeddingModel)} ()} instead
* to configure and create instances of WeaviateVectorStore with default settings
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public static WeaviateVectorStoreConfig defaultConfig() {
return builder().build();
}
/**
* Defines the consistency levels for Weaviate operations.
*
* @see <a href=
* "https://weaviate.io/developers/weaviate/concepts/replication-architecture/consistency#tunable-consistency-strategies">Weaviate
* Consistency Strategies</a>
* @deprecated Use {@link WeaviateVectorStore.ConsistentLevel} instead. This enum
* will be removed in a future release. Example migration: <pre>{@code
* // Old approach:
* WeaviateVectorStoreConfig.ConsistentLevel level = WeaviateVectorStoreConfig.ConsistentLevel.QUORUM;
*
* // New approach:
* WeaviateVectorStore.ConsistentLevel level = WeaviateVectorStore.ConsistentLevel.QUORUM;
* }</pre>
* @since 1.0.0
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public enum ConsistentLevel {
/**
* Write must receive an acknowledgement from at least one replica node. This
* is the fastest (most available), but least consistent option.
*/
ONE,
/**
* Write must receive an acknowledgement from at least QUORUM replica nodes.
* QUORUM is calculated as n / 2 + 1, where n is the number of replicas.
*/
QUORUM,
/**
* Write must receive an acknowledgement from all replica nodes. This is the
* most consistent, but 'slowest'.
*/
ALL
}
/**
* Represents a metadata field configuration for Weaviate vector store.
*
* @param name the name of the metadata field
* @param type the type of the metadata field
* @deprecated Use {@link WeaviateVectorStore.MetadataField} instead. This record
* will be removed in a future release. Example migration: <pre>{@code
* // Old approach:
* WeaviateVectorStoreConfig.MetadataField field = WeaviateVectorStoreConfig.MetadataField.text("field");
*
* // New approach:
* WeaviateVectorStore.MetadataField field = WeaviateVectorStore.MetadataField.text("field");
* }</pre>
* @since 1.0.0
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public record MetadataField(String name, Type type) {
/**
* Creates a metadata field of type TEXT.
* @param name the name of the field
* @return a new MetadataField instance of type TEXT
* @throws IllegalArgumentException if name is null or empty
* @deprecated Use {@link WeaviateVectorStore.MetadataField#text(String)}
* instead
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public static MetadataField text(String name) {
return new MetadataField(name, Type.TEXT);
}
/**
* Creates a metadata field of type NUMBER.
* @param name the name of the field
* @return a new MetadataField instance of type NUMBER
* @throws IllegalArgumentException if name is null or empty
* @deprecated Use {@link WeaviateVectorStore.MetadataField#number(String)}
* instead
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public static MetadataField number(String name) {
return new MetadataField(name, Type.NUMBER);
}
/**
* Creates a metadata field of type BOOLEAN.
* @param name the name of the field
* @return a new MetadataField instance of type BOOLEAN
* @throws IllegalArgumentException if name is null or empty
* @deprecated Use {@link WeaviateVectorStore.MetadataField#bool(String)}
* instead
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public static MetadataField bool(String name) {
return new MetadataField(name, Type.BOOLEAN);
}
/**
* Defines the supported types for metadata fields.
*
* @deprecated Use {@link WeaviateVectorStore.MetadataField.Type} instead.
* This enum will be removed in a future release.
* @since 1.0.0
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public enum Type {
TEXT, NUMBER, BOOLEAN
}
}
/**
* Builder for WeaviateVectorStoreConfig.
*
* @deprecated Use
* {@link WeaviateVectorStore#builder(WeaviateClient, EmbeddingModel)} ()} instead
* to configure and create instances of WeaviateVectorStore
* @since 1.0.0
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public static final class Builder {
private String objectClass = "SpringAiWeaviate";
private ConsistentLevel consistencyLevel = ConsistentLevel.ONE;
private List<MetadataField> filterMetadataFields = List.of();
private Map<String, String> headers = Map.of();
private Builder() {
}
/**
* Configures the filterable metadata fields.
* @param filterMetadataFields known metadata fields to use
* @return this builder
* @throws IllegalArgumentException if filterMetadataFields is null
* @deprecated Use
* {@link WeaviateVectorStore.Builder#filterMetadataFields(List)} instead
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public Builder withFilterableMetadataFields(List<MetadataField> filterMetadataFields) {
Assert.notNull(filterMetadataFields, "The filterMetadataFields can not be null.");
this.filterMetadataFields = filterMetadataFields;
return this;
}
/**
* Configures the Weaviate config headers.
* @param headers config headers to use
* @return this builder
* @throws IllegalArgumentException if headers is null
* @deprecated Use the new builder API in
* {@link WeaviateVectorStore#builder(WeaviateClient, EmbeddingModel)} ()}
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public Builder withHeaders(Map<String, String> headers) {
Assert.notNull(headers, "The headers can not be null.");
this.headers = headers;
return this;
}
/**
* Configures the Weaviate objectClass.
* @param objectClass objectClass to use
* @return this builder
* @throws IllegalArgumentException if objectClass is empty or null
* @deprecated Use {@link WeaviateVectorStore.Builder#objectClass(String)}
* instead
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public Builder withObjectClass(String objectClass) {
Assert.hasText(objectClass, "The objectClass can not be empty.");
this.objectClass = objectClass;
return this;
}
/**
* Configures the Weaviate consistencyLevel.
* @param consistencyLevel consistencyLevel to use
* @return this builder
* @throws IllegalArgumentException if consistencyLevel is null
* @deprecated Use
* {@link WeaviateVectorStore.Builder#consistencyLevel(WeaviateVectorStore.ConsistentLevel)}
* instead
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public Builder withConsistencyLevel(ConsistentLevel consistencyLevel) {
Assert.notNull(consistencyLevel, "The consistencyLevel can not be null.");
this.consistencyLevel = consistencyLevel;
return this;
}
/**
* Builds and returns the immutable configuration.
* @return the immutable configuration
* @deprecated Use
* {@link WeaviateVectorStore#builder(WeaviateClient, EmbeddingModel)} ()}
* instead to configure and create instances of WeaviateVectorStore
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public WeaviateVectorStoreConfig build() {
return new WeaviateVectorStoreConfig(this);
}
}
}
}