Skip to content

API Reference parrot.stores.milvus

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.stores.milvus

View source

MilvusStore: Vector Store implementation using Milvus.

Provides vector similarity search with:

  • Milvus collection management
  • Multiple distance metrics (Cosine, L2, Inner Product)
  • Metadata filtering via dynamic fields
  • Async context manager support
  • Document CRUD operations

Alias AbstractStore

Re-exported from parrot.stores.abstract.AbstractStore.

Alias DistanceStrategy

Re-exported from parrot.stores.models.DistanceStrategy.

Alias Document

Re-exported from parrot.stores.models.Document.

Attribute MILVUS_AVAILABLE

Alias MILVUS_CA_CERT

Re-exported from parrot.conf.MILVUS_CA_CERT.

Alias MILVUS_HOST

Re-exported from parrot.conf.MILVUS_HOST.

Alias MILVUS_PASSWORD

Re-exported from parrot.conf.MILVUS_PASSWORD.

Alias MILVUS_PORT

Re-exported from parrot.conf.MILVUS_PORT.

Alias MILVUS_PROTOCOL

Re-exported from parrot.conf.MILVUS_PROTOCOL.

Alias MILVUS_SECURE

Re-exported from parrot.conf.MILVUS_SECURE.

Alias MILVUS_SERVER_CERT

Re-exported from parrot.conf.MILVUS_SERVER_CERT.

Alias MILVUS_SERVER_KEY

Re-exported from parrot.conf.MILVUS_SERVER_KEY.

Alias MILVUS_SERVER_NAME

Re-exported from parrot.conf.MILVUS_SERVER_NAME.

Alias MILVUS_TOKEN

Re-exported from parrot.conf.MILVUS_TOKEN.

Alias MILVUS_URL

Re-exported from parrot.conf.MILVUS_URL.

Alias MILVUS_USER

Re-exported from parrot.conf.MILVUS_USER.

Alias MILVUS_USE_TLSv2

Re-exported from parrot.conf.MILVUS_USE_TLSv2.

Class MilvusStore

A Milvus vector store implementation using pymilvus MilvusClient.

This store interacts with a Milvus instance for vector similarity search, document management, and collection operations.

Parameter Type Default Description
collection_name str 'default' Name of the Milvus collection.
id_column str 'id' Name of the primary key field.
embedding_column str 'embedding' Name of the vector field.
document_column str 'document' Name of the document content field.
text_column str 'text' Name of the text field.
metadata_column str 'metadata' Name of the metadata field (stored as JSON string).
embedding_model Union[dict, str] 'sentence-transformers/all-mpnet-base-v2' Embedding model configuration.
embedding Optional[Callable] None Custom embedding callable.
distance_strategy DistanceStrategy DistanceStrategy.COSINE Distance metric to use.
index_type str 'IVF_FLAT' Milvus index type (IVF_FLAT, HNSW, FLAT, etc.).
nlist int 128 Number of clusters for IVF indexes.
nprobe int 16 Number of clusters to probe for IVF search.
ef_construction int 200 HNSW construction parameter.
ef int 100 HNSW search parameter.
auto_create bool False Automatically create collection on connect if missing.
uri Optional[str] None Milvus server URI. If not provided, built from config.
token Optional[str] None Authentication token. If not provided, read from config.
**kwargs {}

Method MilvusStore.connection

Establish connection to the Milvus server.

connection() -> None

Method MilvusStore.disconnect

Close the Milvus connection.

disconnect() -> None

Method MilvusStore.initialize_database

Initialize database-level resources.

For Milvus this is a no-op; collections are created explicitly.

initialize_database() -> None

Method MilvusStore.get_distance_strategy

Return the Milvus metric type string for the current strategy.

get_distance_strategy(metric: Optional[str] = None, **kwargs) -> str

Parameter Type Default Description
metric Optional[str] None Optional override metric string.
**kwargs {}

Returns: str — A Milvus-compatible metric type string (e.g. "COSINE").

Method MilvusStore.get_vector

Return the underlying MilvusClient instance.

get_vector(metric_type: str = None, **kwargs)

Parameter Type Default Description
metric_type str None
**kwargs {}

Method MilvusStore.collection_exists

Check whether a collection exists in Milvus.

collection_exists(collection: str = None) -> bool

Parameter Type Default Description
collection str None Collection name. Defaults to self.collection_name.

Returns: bool — True if the collection exists.

Method MilvusStore.create_collection

Create a new collection in Milvus with a vector index.

create_collection(collection: str = None, dimension: int = None, metric_type: str = None, index_type: str = None, **kwargs) -> None

Parameter Type Default Description
collection str None Collection name.
dimension int None Vector dimension. Defaults to self.dimension.
metric_type str None Distance metric. Defaults to configured strategy.
index_type str None Index algorithm. Defaults to self._index_type.
**kwargs {}

Method MilvusStore.drop_collection

Drop a collection from Milvus.

drop_collection(collection: str = None) -> None

Parameter Type Default Description
collection str None Collection name to drop.

Method MilvusStore.create_embedding_table

Alias for create_collection to match PgVectorStore interface.

create_embedding_table(collection: str = None, dimension: int = None, metric_type: str = None, index_type: str = None, **kwargs) -> None

Parameter Type Default Description
collection str None
dimension int None
metric_type str None
index_type str None
**kwargs {}

Method MilvusStore.prepare_embedding_table

Prepare a collection as an embedding table.

For Milvus this delegates to create_collection since Milvus collections are schemaless beyond the defined fields.

prepare_embedding_table(tablename: str, conn: Any = None, embedding_column: str = 'embedding', document_column: str = 'document', metadata_column: str = 'metadata', dimension: int = None, id_column: str = 'id', use_jsonb: bool = True, drop_columns: bool = False, create_all_indexes: bool = True, **kwargs) -> None

Parameter Type Default Description
tablename str
conn Any None
embedding_column str 'embedding'
document_column str 'document'
metadata_column str 'metadata'
dimension int None
id_column str 'id'
use_jsonb bool True
drop_columns bool False
create_all_indexes bool True
**kwargs {}

Method MilvusStore.add_documents

Add documents to a Milvus collection.

Each document is embedded, assigned a UUID, and inserted together with its text content and metadata.

add_documents(documents: List[Document], collection: str = None, **kwargs) -> None

Parameter Type Default Description
documents List[Document] List of Document objects.
collection str None Target collection name.
**kwargs {}

Method MilvusStore.from_documents

Create the collection (if needed) and add documents.

from_documents(documents: List[Any], collection: str = None, **kwargs) -> MilvusStore

Parameter Type Default Description
documents List[Any] List of Document objects.
collection str None Collection name.
**kwargs {}

Returns: MilvusStore — self for chaining.

Method MilvusStore.update_documents_by_filter

Update documents matching a metadata filter.

Milvus does not support in-place updates; this method performs a query-delete-reinsert cycle for matching documents.

update_documents_by_filter(updates: Dict[str, Any], filter_dict: Dict[str, Any], collection: str = None, **kwargs) -> int

Parameter Type Default Description
updates Dict[str, Any] Dictionary of field values to update.
filter_dict Dict[str, Any] Metadata filter criteria.
collection str None Collection name.
**kwargs {}

Returns: int — Number of updated documents.

Method MilvusStore.delete_documents

Delete documents by metadata field values.

delete_documents(documents: Optional[List[Document]] = None, pk: str = 'source_type', values: Optional[Union[str, List[str]]] = None, table: Optional[str] = None, schema: Optional[str] = None, collection: Optional[str] = None, **kwargs) -> int

Parameter Type Default Description
documents Optional[List[Document]] None If provided, extract pk values from metadata.
pk str 'source_type' Metadata key to match against.
values Optional[Union[str, List[str]]] None Explicit value(s) to match.
table Optional[str] None
schema Optional[str] None
collection Optional[str] None Collection name override.
**kwargs {}

Returns: int — Number of deleted documents.

Method MilvusStore.delete_documents_by_filter

Delete documents matching multiple metadata conditions.

delete_documents_by_filter(search_filter: Dict[str, Union[str, List[str]]], table: Optional[str] = None, schema: Optional[str] = None, collection: Optional[str] = None, **kwargs) -> int

Parameter Type Default Description
search_filter Dict[str, Union[str, List[str]]] Dictionary of metadata field → value(s).
table Optional[str] None
schema Optional[str] None
collection Optional[str] None Collection name override.
**kwargs {}

Returns: int — Number of deleted documents.

Method MilvusStore.delete_documents_by_ids

Delete documents by their primary key IDs.

delete_documents_by_ids(document_ids: List[str], collection: Optional[str] = None, **kwargs) -> int

Parameter Type Default Description
document_ids List[str] List of document IDs to delete.
collection Optional[str] None Collection name override.
**kwargs {}

Returns: int — Number of deleted documents.

Method MilvusStore.similarity_search

Perform vector similarity search against a Milvus collection.

similarity_search(query: str, collection: str = None, limit: int = 10, similarity_threshold: float = 0.0, search_strategy: str = 'auto', metadata_filters: Optional[Dict[str, Any]] = None, metric: str = None, additional_columns: Optional[List[str]] = None, **kwargs) -> List[SearchResult]

Parameter Type Default Description
query str Search query text.
collection str None Collection name.
limit int 10 Maximum number of results.
similarity_threshold float 0.0 Minimum score threshold.
search_strategy str 'auto'
metadata_filters Optional[Dict[str, Any]] None Metadata key/value filter conditions.
metric str None Distance metric override.
additional_columns Optional[List[str]] None Extra fields to return.
**kwargs {}

Returns: List[SearchResult] — List of SearchResult objects ordered by relevance.

Method MilvusStore.document_search

Search with chunk-awareness support.

document_search(query: str, collection: str = None, limit: int = 10, search_chunks: bool = True, search_full_docs: bool = False, **kwargs) -> List[SearchResult]

Parameter Type Default Description
query str Search query text.
collection str None Collection name.
limit int 10 Number of results.
search_chunks bool True Search chunk-level embeddings.
search_full_docs bool False Also search full-document embeddings.
**kwargs {}

Returns: List[SearchResult] — List of SearchResult objects.

Alias SearchResult

Re-exported from parrot.stores.models.SearchResult.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally