rig-milvus

Crates.iorig-milvus
lib.rsrig-milvus
version0.1.11
created_at2025-06-09 16:42:36.337594+00
updated_at2025-09-15 22:05:58.858+00
descriptionMilvus vector store implementation for the rig framework
homepage
repository
max_upload_size
id1706141
size75,006
(cvauclair)

documentation

README

Rig Milvus integration

This crate integrates Milvus into Rig, allowing you to easily use RAG with this database.

Installation

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:

  • an ID field (auto-generated as i64 but converted to String when using top_n())
  • an embedding field for storing vectors
  • a document field (for storing metadata)
  • an embeddedText field (for the actual item that was embedded)

Once done, you'll now be ready to use!

How to run the example

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
Commit count: 0

cargo fmt