milvus

package module
v0.18.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 10, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package milvus exposes Milvus / Zilliz Cloud through the Core vector-store capability interfaces. Documents are stored as rows in a Milvus collection (`{id, content, embedding, <metadata columns>}`); retrieval runs Milvus's ANN search. Documents containing media are rejected before indexing I/O because this adapter persists document text and metadata only.

Requirements: a reachable Milvus 2.x server (self-hosted, Docker, or Zilliz Cloud managed service). The store uses the official milvus-sdk-go/v2 gRPC client.

Vector similarity functions: cosine / L2 / IP. The chosen value is bound to the collection's index at creation time; switching requires rebuilding the index.

Schema. Milvus is strongly typed — every metadata field that participates in filters must be declared as a typed column at schema-creation time. [StoreConfig.MetadataFields] enumerates the columns; anything outside that set goes into a flexible JSON field that can still be filtered but at a higher cost.

Filter visitor produces Milvus's expression language — `author == "Alice" and (year > 2020 or tag in ["a","b"])`. The result feeds the `expr` parameter of the search call.

Upsert acknowledgment. Milvus answers an upsert with the number of rows it accepted; Index requires that count to match what it sent rather than treating a short write as a complete one.

Scoring. The three metrics report three different quantities, so each has its own mapping. COSINE is a similarity in [-1, 1]. L2 is the squared distance — Milvus stops before the square root — which still ranks correctly. IP is the raw inner product with no normalization, so it is unbounded unless the caller supplies unit vectors and cannot share the cosine mapping.

Null tests are refused. Milvus' expression syntax documents no IS NULL and no way to test whether a JSON key is present — its JSON operators are JSON_CONTAINS and its variants — so an IS NULL filter fails rather than being approximated by a value comparison that would answer differently.

See https://milvus.io/docs for the full API surface.

Index

Constants

View Source
const (
	Provider = "Milvus"
)

Provider is the stable backend name for host-side attribution.

Variables

View Source
var (
	ErrMissingClient = errors.New("milvus: Client is required")

	ErrMissingCollectionName = errors.New("milvus: CollectionName is required")

	ErrMissingEmbeddingModel = errors.New("milvus: EmbeddingModel is required")

	ErrMissingDocumentBatcher = errors.New("milvus: DocumentBatcher is required")

	ErrDocumentIDTooLong = errors.New("milvus: document ID exceeds the 36-byte limit")

	ErrDocumentContentTooLong = errors.New("milvus: document text exceeds the 65535-byte limit")
)

Functions

This section is empty.

Types

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store implements vectorstore.Store against a Milvus collection. Milvus requires a loaded collection before search, which is why the collection is resolved once at construction rather than per query.

func NewStore

func NewStore(ctx context.Context, config StoreConfig) (*Store, error)

NewStore performs schema setup during construction, which is why it takes a context: a store returned before its collection exists would fail on the first index rather than at wiring, where the misconfiguration actually is.

func (*Store) Close

func (s *Store) Close(ctx context.Context) error

func (*Store) DeleteIDs

func (s *Store) DeleteIDs(ctx context.Context, ids []string) (err error)

DeleteIDs removes rows by primary key. WithStringIDs compiles to the expr `id in ["a","b"]`, so unknown ids are silently ignored (idempotent). An empty slice is a no-op. Implements vectorstore.IDDeleter.

func (*Store) DeleteWhere

func (s *Store) DeleteWhere(ctx context.Context, expr filter.Predicate) (err error)

func (*Store) Index

func (s *Store) Index(ctx context.Context, request *vectorstore.IndexRequest) (err error)

func (*Store) Search

func (s *Store) Search(ctx context.Context, req *vectorstore.SearchRequest) (response *vectorstore.SearchResponse, err error)

type StoreConfig

type StoreConfig struct {
	// Client is the Milvus client instance.
	// Required: must be provided, otherwise initialization will fail.
	Client *milvusclient.Client

	// CollectionName is the name of the Milvus collection.
	// Required: must be a non-empty string.
	CollectionName string

	// InitializeSchema indicates whether to automatically create the collection
	// and its vector index if they do not exist.
	// Optional: defaults to false.
	InitializeSchema bool

	// EmbeddingModel is the model used to generate vector embeddings from text.
	// Required: must be provided.
	EmbeddingModel embedding.Model

	// DocumentBatcher is responsible for batching documents before insertion.
	// Required: must be provided.
	DocumentBatcher vectorstore.Batcher

	// Dimensions stays explicit because creating a collection must not trigger
	// a hidden, billable embedding request.
	Dimensions int

	// MetricType is the similarity metric used when creating the vector index.
	// Optional: defaults to entity.COSINE.
	MetricType entity.MetricType
}

StoreConfig contains configuration options for Milvus vector store.

func (StoreConfig) Validate

func (s StoreConfig) Validate() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL