Configuration and Options
Relevant source files
The following files were used as context for generating this wiki page:
The Milvus Rust SDK utilizes a combination of builder patterns and option structures to manage configurations across databases, collections, searches, and indexing. These options allow developers to fine-tune system behavior, including resource allocation (disk quotas, replicas), consistency levels, and performance tuning for vector searches.
Configuration is primarily handled through gRPC request structures defined in the protocol buffers, which are abstracted into user-friendly Rust structs. Key areas of configuration include database-level properties, search-time parameters, and index build specifications.
Database Configuration
Databases in Milvus serve as logical containers that can be configured with specific resource constraints and access controls. The SDK provides CreateDbOptions to define these parameters during creation or modification.
CreateDbOptions Architecture
The CreateDbOptions struct implements a builder pattern to allow incremental configuration of database properties. These properties are eventually converted into a vector of KeyValuePair objects for gRPC transmission.
The diagram shows the flow of database configuration from the high-level builder to the low-level gRPC key-value pairs.
Sources: src/database.rs:56-78, src/database.rs:400-447
Database Property Parameters
The following table summarizes the configurable options available at the database level:
| Property | Type | Description | Key (Server-side) |
|---|---|---|---|
replica_number | i32 | Number of replicas for the database | database.replica.number |
resource_groups | Vec<String> | Dedicated resource groups | database.resource_groups |
diskquota_mb | i32 | Allocated disk quota in MB | database.diskQuota.mb |
max_collections | i32 | Max allowed collections | database.max.collections |
force_deny_writing | bool | Deny all write operations | database.force.deny.writing |
force_deny_reading | bool | Deny all read operations | database.force.deny.reading |
Sources: src/database.rs:85-155, src/database.rs:408-444
Search and Query Options
Search operations require specific tuning parameters to balance accuracy and latency. These are configured through structures like SearchOptions and QueryOptions.
Consistency Levels
Milvus supports various consistency levels to determine data visibility during concurrent operations. These are defined in the ConsistencyLevel enumeration.
This diagram illustrates the hierarchy of consistency levels available for search and query requests.
Sources: src/proto/milvus.proto.common.rs:777-789
Search Parameters
Search requests utilize the SearchRequest structure, which includes parameters for partitioning, output fields, and metric types.
| Field | Type | Description |
|---|---|---|
partition_names | Vec<String> | Partitions to search within |
output_fields | Vec<String> | Fields to return in results |
search_params | Vec<KeyValuePair> | Extra params like nprobe or metric_type |
guarantee_timestamp | u64 | Used for customized consistency |
Sources: src/proto/milvus.proto.milvus.rs:431-470, examples/query_search.rs:57-69
Indexing Configuration
Index creation is configured via IndexParams, which specify the algorithm used for vector similarity search.
Index Build Logic
When creating an index, the SDK uses CreateIndexRequest. The process is often asynchronous, and the SDK provides utilities to wait for the index state to reach Finished.
The sequence shows the polling mechanism used by the SDK to ensure an index is fully built before returning.
Sources: src/index/utils.rs:48-84, src/proto/milvus.proto.common.rs:604-611
Index States
Indexes can exist in several states during their lifecycle, as defined by the IndexState enum:
Unissued: Task not yet started.InProgress: Indexing is currently running.Finished: Indexing successfully completed.Failed: Index build failed.
Sources: src/proto/milvus.proto.common.rs:604-611
Authentication and Security Options
The SDK manages user credentials and role-based access control (RBAC) through specific request structures.
User Management Options
When creating or updating users, the SDK handles password security by encoding secrets before gRPC transport.
pub async fn create_user<S: Into<String>>(&self, user_name: S, password: S) -> Result<()> {
let res = self.client.clone().create_credential(proto::milvus::CreateCredentialRequest {
base: Some(MsgBase::new(MsgType::CreateCredential)),
username: user_name.into(),
password: general_purpose::STANDARD.encode(password.into().as_bytes()),
..Default::default()
}).await?.into_inner();
status_to_result(&Some(res))
}
Sources: src/authentication.rs:82-97, src/authentication.rs:710-720
Privilege Levels
Permissions are configured at different granularities, defined by PrivilegeLevel:
- Cluster: Global administrative permissions.
- Database: Permissions scoped to a specific database.
- Collection: Permissions scoped to a specific collection within a database.
Sources: src/proto/milvus.proto.milvus.rs:1044-1051
Summary
The Milvus Rust SDK provides a robust configuration system through builder-pattern options and gRPC-aligned structures. By utilizing CreateDbOptions for resources, SearchOptions for query performance, and IndexParams for vector search optimization, developers can effectively manage the behavior and performance of their Milvus cluster from a type-safe Rust environment.