| Crates.io | rig-milvus |
| lib.rs | rig-milvus |
| version | 0.1.11 |
| created_at | 2025-06-09 16:42:36.337594+00 |
| updated_at | 2025-09-15 22:05:58.858+00 |
| description | Milvus vector store implementation for the rig framework |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1706141 |
| size | 75,006 |
This crate integrates Milvus into Rig, allowing you to easily use RAG with this database.
To install this crate, run the following command in a Rust project directory which will add rig-milvus as a dependency (requires rig-core added for intended usage):
cargo add rig-milvus
There's a couple of different ways you can run Milvus:
Before creating a collection that is compliant with rig-milvus, ensure you set up your Milvus related environment variables:
export MILVUS_DATABASE_NAME=
export MILVUS_COLLECTION_NAME=
export MILVUS_USERNAME=
export MILVUS_PASSWORD=
export MILVUS_BASE_URL=
To create a collection, you will need the bash script below.
export TOKEN="${MILVUS_USERNAME}:${MILVUS_PASSWORD}"
curl --request POST \
--url "${MILVUS_BASE_URL}/v2/vectordb/collections/create" \
--header "Authorization: Bearer ${TOKEN}" \
--header "Content-Type: application/json" \
-d '{
"collectionName": "${MILVUS_COLLECTION_NAME}",
"dbName": "${MILVUS_DATABASE_NAME}",
"schema": {
"autoId": true,
"enabledDynamicField": false,
"fields": [
{
"fieldName": "embedding",
"dataType": "FloatVector",
"elementTypeParams": {
"dim": "1536"
}
},
{
"fieldName": "document",
"dataType": "JSON",
},
{
"fieldName": "embeddedText",
"dataType": "VarChar"
}
]
}
}'
This will create a collection with the following fields:
top_n())embedding field for storing vectorsdocument field (for storing metadata)embeddedText field (for the actual item that was embedded)Once done, you'll now be ready to use!
To run the example, add your OpenAI API key as an environment variable. Don't forget your Milvus username, password, database & collection name and endpoint URL if you're executing this from a new terminal tab/window:
export OPENAI_API_KEY=my_key
export MILVUS_DATABASE_NAME=
export MILVUS_COLLECTION_NAME=
export MILVUS_USERNAME=
export MILVUS_PASSWORD=
export MILVUS_BASE_URL=
Finally, use the following command below to run the example:
cargo run --example vector_search_milvus --features rig-core/derive