milvus

package module
v0.61.0 Latest Latest
Warning

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

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

Documentation

Overview

Package milvus writes precalculated vectors and searches a provisioned Milvus collection. Set the schema description to SpaceID.StorageKey(). The adapter verifies the actual collection, exact field policy and active vector index metric. The Host owns collection provisioning and the client.

Query performs native ranking without enumerating the collection. A metadata predicate on opaque Core JSON needs an explicitly authorized QueryByScan and a ScanBudget. QueryByScan validates every visited record and rechecks returned membership; pagination and native ranking do not form a global snapshot.

Upsert validates all columns before the RPC, never scans unrelated records, and does not confuse a lost or inconsistent mutation receipt with success.

Index

Examples

Constants

View Source
const (
	Provider = "Milvus"
)

Variables

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

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

	// ErrSchemaMismatch means the existing collection cannot preserve this
	// store's document, vector, or score contract.
	ErrSchemaMismatch = errors.New("milvus: collection schema or vector index does not have the current policy")

	ErrDocumentIDTooLong = errors.New("milvus: document ID exceeds the native VARCHAR capacity")

	ErrDocumentContentTooLong = errors.New("milvus: document text exceeds the native VARCHAR capacity")
)

Functions

This section is empty.

Types

type Store

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

func NewStore

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

import (
	"context"
	"os"

	"github.com/milvus-io/milvus/client/v3/milvusclient"

	"github.com/Tangerg/scope/core/document"

	"github.com/Tangerg/scope/core/vectorstore"
	"github.com/Tangerg/scope/vectorstores/milvus"
)

func main() {
	ctx := context.Background()
	client, err := milvusclient.New(ctx, &milvusclient.ClientConfig{Address: os.Getenv("SCOPE_MILVUS_ADDRESS")})
	if err != nil {
		panic(err)
	}
	defer client.Close(ctx)
	const space vectorstore.SpaceID = "encoder-v1"
	store, err := milvus.NewStore(ctx, milvus.StoreConfig{Client: client, CollectionName: "documents", Space: space})
	if err != nil {
		panic(err)
	}
	batch := &vectorstore.Batch{Space: space, Records: []vectorstore.Record{{Document: &document.Document{ID: "one", Text: "example"}, Values: []float64{1, 0}}}}
	if err = store.Upsert(ctx, batch); err != nil {
		panic(err)
	}
	if _, err = store.Query(ctx, &vectorstore.Query{Space: space, Values: []float64{1, 0}}); err != nil {
		panic(err)
	}
	if err := store.DeleteIDs(ctx, []string{"one"}); err != nil {
		panic(err)
	}
}

func (*Store) CheckDocuments added in v0.59.0

func (s *Store) CheckDocuments(ctx context.Context, space vectorstore.SpaceID, docs []*document.Document) error

func (*Store) CheckQuery added in v0.59.0

func (s *Store) CheckQuery(ctx context.Context, space vectorstore.SpaceID, opts vectorstore.SearchOptions) error

func (*Store) DeleteIDs

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

func (*Store) Query added in v0.59.0

func (*Store) QueryByScan added in v0.60.0

func (*Store) Upsert added in v0.59.0

func (s *Store) Upsert(ctx context.Context, batch *vectorstore.Batch) error

type StoreConfig

type StoreConfig struct {
	// Client owns authentication, transport, retries and lifetime.
	Client         *milvusclient.Client
	CollectionName string
	Space          vectorstore.SpaceID
}

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