Package io.agentscope.core.rag.store
Class MilvusStore.Builder
java.lang.Object
io.agentscope.core.rag.store.MilvusStore.Builder
- Enclosing class:
- MilvusStore
Builder for creating MilvusStore instances with fluent configuration.
Example usage:
MilvusStore store = MilvusStore.builder()
.uri("http://localhost:19530")
.collectionName("my_collection")
.dimensions(1024)
.token("root:Milvus")
.connectTimeoutMs(30000)
.metricType(IndexParam.MetricType.COSINE)
.build();
-
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds a new MilvusStore instance.collectionName(String collectionName) Sets the collection name.connectTimeoutMs(long connectTimeoutMs) Sets the connection timeout in milliseconds.databaseName(String databaseName) Sets the database name.databaseProperties(Map<String, String> databaseProperties) Sets the database properties.dimensions(int dimensions) Sets the vector dimensions.metricType(io.milvus.v2.common.IndexParam.MetricType metricType) Sets the metric type for vector similarity search.Sets the password for authentication.Sets the authentication token.Sets the Milvus server URI.Sets the username for authentication.
-
Method Details
-
uri
Sets the Milvus server URI.- Parameters:
uri- the Milvus server URI (e.g., "http://localhost:19530")- Returns:
- this builder
-
collectionName
Sets the collection name.- Parameters:
collectionName- the name of the collection to use- Returns:
- this builder
-
dimensions
Sets the vector dimensions.- Parameters:
dimensions- the dimension of vectors that will be stored- Returns:
- this builder
-
token
Sets the authentication token.The token should be in the format "username:password" for basic authentication.
- Parameters:
token- the authentication token- Returns:
- this builder
-
username
Sets the username for authentication.This is an alternative to using token(). If both are set, token takes precedence.
- Parameters:
username- the username- Returns:
- this builder
-
password
Sets the password for authentication.This should be used together with username().
- Parameters:
password- the password- Returns:
- this builder
-
connectTimeoutMs
Sets the connection timeout in milliseconds.Default is 30000 (30 seconds). Set to 0 or negative to disable timeout.
- Parameters:
connectTimeoutMs- the connection timeout in milliseconds- Returns:
- this builder
-
metricType
Sets the metric type for vector similarity search.Default is COSINE. Other options include L2 (Euclidean) and IP (Inner Product). When opening an existing collection, this must match the collection's vector index. L2 distances are converted to
1 / (1 + distance)scores before thresholding.- Parameters:
metricType- the metric type- Returns:
- this builder
-
databaseName
Sets the database name.- Parameters:
databaseName- the database name- Returns:
- this builder
-
databaseProperties
Sets the database properties.- Parameters:
databaseProperties- the database properties- Returns:
- this builder
-
build
Builds a new MilvusStore instance.The client connection is established immediately during construction. If the connection fails or the collection cannot be created, a VectorStoreException is thrown.
- Returns:
- a new MilvusStore instance
- Throws:
IllegalArgumentException- if required parameters are invalidVectorStoreException- if client initialization or collection creation fails
-