agrag.vectordb.milvus.MilvusVectorStore
MilvusVectorStore(settings:MilvusSettings | None = None, *, tracer:Tracer | None = None) -> None
Bases: VectorStore
Store UUID-keyed vectors with server-generated BM25 sparse vectors.
Dense scores match graph-native cosine and Euclidean scores. Hybrid scores use Milvus's normalized weighted ranking; alpha endpoints use a single search path so a zero-weight path cannot add hits. All reads use Strong consistency.
Functions:
- close – Release the connection; a later initialize reconnects.
- collection_info – Return schema metadata and the record count, or None when absent.
- collection_name – Return the prefixed collection name for a kind.
- delete – Delete in batches, ignoring absent IDs and collections.
- delete_collection – Drop a collection if it exists.
- ensure_collection – Create and load a collection, or reject dimension and metric mismatches.
- hybrid_search – Fuse normalized dense and BM25 scores; endpoints select one path only.
- initialize – Connect and authenticate, reporting failures without credential values.
- list_ids – Page UUIDs in ascending order with an exclusive keyset cursor.
- search – Return dense hits with graph-native scores, best first.
- upsert – Overwrite records by UUID, truncating only stored BM25 text to 65535 bytes.
Attributes:
- collection_prefix –
- max_results (
int) – - name (
str) – - settings –
close
close() -> None
Release the connection; a later initialize reconnects.
collection_info
collection_info(kind:VectorKind, *, exact_count:bool = True) -> CollectionInfo | None
Return schema metadata and the record count, or None when absent.
Parameters:
- kind (
VectorKind) – The collection to describe. - exact_count (
bool) – Run a Strong count that includes unflushed writes. When false, use the collection statistics, which can lag recent writes.
collection_name
collection_name(kind:VectorKind) -> str
Return the prefixed collection name for a kind.
collection_prefix
collection_prefix = self.settings.collection_prefix
delete
delete(kind:VectorKind, ids:Sequence[UUID]) -> None
Delete in batches, ignoring absent IDs and collections.
A server failure can leave earlier batches applied. Retry the same IDs to finish an interrupted deletion; deleting an absent ID is harmless.
delete_collection
delete_collection(kind:VectorKind) -> None
Drop a collection if it exists.
ensure_collection
ensure_collection(kind:VectorKind, *, dimensions:int, distance:Distance) -> None
Create and load a collection, or reject dimension and metric mismatches.
hybrid_search
hybrid_search(kind:VectorKind, vector:Sequence[float], text:str, *, limit:int, alpha:float, labels:Sequence[str] | None = None) -> list[VectorHit]
Fuse normalized dense and BM25 scores; endpoints select one path only.
initialize
initialize() -> None
Connect and authenticate, reporting failures without credential values.
list_ids
list_ids(kind:VectorKind, *, after:UUID | None = None, limit:int = 1000) -> list[UUID]
Page UUIDs in ascending order with an exclusive keyset cursor.
Milvus 3.0 sorting orders the canonical VARCHAR UUIDs lexicographically,
which is also UUID numeric order. Pages do not form a concurrent snapshot.
A limit of zero returns no IDs, a negative limit raises ValueError, and a
limit above max_results is capped.
max_results
max_results: int = 16384
name
name: str = 'milvus'
search
search(kind:VectorKind, vector:Sequence[float], *, limit:int, labels:Sequence[str] | None = None) -> list[VectorHit]
Return dense hits with graph-native scores, best first.
settings
settings = settings if settings is not None else MilvusSettings()
upsert
upsert(kind:VectorKind, records:Sequence[VectorRecord], *, batch_size:int = 256) -> None
Overwrite records by UUID, truncating only stored BM25 text to 65535 bytes.
UTF-8 truncation preserves whole characters. The input records and dense vectors remain unchanged. A warning is emitted once per truncated call. Labels allow at most 4096 values, each at most 256 UTF-8 bytes. Invalid labels raise ValueError before any batch is written. A server failure can leave earlier batches applied; retrying the same records is idempotent.