Class MilvusStore.Builder

java.lang.Object
io.agentscope.core.rag.store.MilvusStore.Builder
Enclosing class:
MilvusStore

public static class MilvusStore.Builder extends Object
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 Details

    • uri

      public MilvusStore.Builder uri(String uri)
      Sets the Milvus server URI.
      Parameters:
      uri - the Milvus server URI (e.g., "http://localhost:19530")
      Returns:
      this builder
    • collectionName

      public MilvusStore.Builder collectionName(String collectionName)
      Sets the collection name.
      Parameters:
      collectionName - the name of the collection to use
      Returns:
      this builder
    • dimensions

      public MilvusStore.Builder dimensions(int dimensions)
      Sets the vector dimensions.
      Parameters:
      dimensions - the dimension of vectors that will be stored
      Returns:
      this builder
    • token

      public MilvusStore.Builder token(String 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

      public MilvusStore.Builder username(String 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

      public MilvusStore.Builder password(String password)
      Sets the password for authentication.

      This should be used together with username().

      Parameters:
      password - the password
      Returns:
      this builder
    • connectTimeoutMs

      public MilvusStore.Builder connectTimeoutMs(long 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

      public MilvusStore.Builder metricType(io.milvus.v2.common.IndexParam.MetricType 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

      public MilvusStore.Builder databaseName(String databaseName)
      Sets the database name.
      Parameters:
      databaseName - the database name
      Returns:
      this builder
    • databaseProperties

      public MilvusStore.Builder databaseProperties(Map<String,String> databaseProperties)
      Sets the database properties.
      Parameters:
      databaseProperties - the database properties
      Returns:
      this builder
    • build

      public MilvusStore build() throws VectorStoreException
      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 invalid
      VectorStoreException - if client initialization or collection creation fails