Documentation
¶
Index ¶
- Constants
- type Adapter
- func (a *Adapter) Close() error
- func (a *Adapter) CreateDocument(ctx context.Context, collectionName string, document *vectordb.Document) error
- func (a *Adapter) CreateDocuments(ctx context.Context, collectionName string, documents []*vectordb.Document) error
- func (a *Adapter) GetDefaultSchema(schemaType vectordb.SchemaType, collectionName string) *vectordb.CollectionSchema
- func (a *Adapter) SearchHybrid(ctx context.Context, collectionName, query string, opts *vectordb.QueryOptions) ([]*vectordb.QueryResult, error)
- func (a *Adapter) SearchSemantic(ctx context.Context, collectionName, query string, opts *vectordb.QueryOptions) ([]*vectordb.QueryResult, error)
- func (a *Adapter) UpdateDocument(ctx context.Context, collectionName string, document *vectordb.Document) error
- func (a *Adapter) UpdateSchema(ctx context.Context, collectionName string, schema *vectordb.CollectionSchema) error
- func (a *Adapter) ValidateSchema(schema *vectordb.CollectionSchema) error
- type Client
- func (c *Client) Close() error
- func (c *Client) CollectionExists(ctx context.Context, name string) (bool, error)
- func (c *Client) CreateCollection(ctx context.Context, name string, schema *vectordb.CollectionSchema) error
- func (c *Client) DeleteCollection(ctx context.Context, name string) error
- func (c *Client) DeleteDocument(ctx context.Context, collectionName, documentID string) error
- func (c *Client) DeleteDocuments(ctx context.Context, collectionName string, documentIDs []string) error
- func (c *Client) DeleteDocumentsByMetadata(ctx context.Context, collectionName string, metadata map[string]interface{}) error
- func (c *Client) GetCollectionCount(ctx context.Context, name string) (int64, error)
- func (c *Client) GetDocument(ctx context.Context, collectionName, documentID string) (*vectordb.Document, error)
- func (c *Client) GetSchema(ctx context.Context, name string) (*vectordb.CollectionSchema, error)
- func (c *Client) Health(ctx context.Context) error
- func (c *Client) ListCollections(ctx context.Context) ([]vectordb.CollectionInfo, error)
- func (c *Client) ListDocuments(ctx context.Context, collectionName string, limit, offset int) ([]*vectordb.Document, error)
- func (c *Client) SearchBM25(ctx context.Context, collectionName, query string, opts *vectordb.QueryOptions) ([]*vectordb.QueryResult, error)
- func (c *Client) SearchByMetadata(ctx context.Context, collectionName string, metadata map[string]interface{}, ...) ([]*vectordb.QueryResult, error)
- type Config
- type Factory
Constants ¶
const ( FieldDocumentID = "document_id" FieldText = "text" FieldContent = "content" FieldImage = "image" FieldImageData = "image_data" FieldURL = "url" FieldEmbedding = "embedding" FieldMetadata = "metadata" FieldCreatedAt = "created_at" FieldUpdatedAt = "updated_at" FieldImageThumbnail = "image_thumbnail" // External storage: thumbnail (base64, <47KB) FieldImageURL = "image_url" // External storage: full image URL (S3/MinIO) FieldImageMetadata = "image_metadata" // External storage: image metadata (JSON) )
Collection field names (standardized across all collections)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter struct {
*Client
// contains filtered or unexported fields
}
Adapter wraps the Milvus client to implement the vectordb.VectorDBClient interface
func NewAdapter ¶
NewAdapter creates a new Milvus adapter from the vectordb.Config
func (*Adapter) CreateDocument ¶
func (a *Adapter) CreateDocument(ctx context.Context, collectionName string, document *vectordb.Document) error
CreateDocument creates a new document in the specified collection
func (*Adapter) CreateDocuments ¶
func (a *Adapter) CreateDocuments(ctx context.Context, collectionName string, documents []*vectordb.Document) error
CreateDocuments creates multiple documents in batch
func (*Adapter) GetDefaultSchema ¶
func (a *Adapter) GetDefaultSchema(schemaType vectordb.SchemaType, collectionName string) *vectordb.CollectionSchema
GetDefaultSchema returns a default schema for the given type
func (*Adapter) SearchHybrid ¶
func (a *Adapter) SearchHybrid(ctx context.Context, collectionName, query string, opts *vectordb.QueryOptions) ([]*vectordb.QueryResult, error)
SearchHybrid performs hybrid search combining vector and keyword search
func (*Adapter) SearchSemantic ¶
func (a *Adapter) SearchSemantic(ctx context.Context, collectionName, query string, opts *vectordb.QueryOptions) ([]*vectordb.QueryResult, error)
SearchSemantic performs semantic search using Milvus vector search
func (*Adapter) UpdateDocument ¶
func (a *Adapter) UpdateDocument(ctx context.Context, collectionName string, document *vectordb.Document) error
UpdateDocument updates an existing document (delete + insert)
func (*Adapter) UpdateSchema ¶
func (a *Adapter) UpdateSchema(ctx context.Context, collectionName string, schema *vectordb.CollectionSchema) error
UpdateSchema updates a collection's schema
func (*Adapter) ValidateSchema ¶
func (a *Adapter) ValidateSchema(schema *vectordb.CollectionSchema) error
ValidateSchema validates a schema definition
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps the Milvus client with vector database functionality
func (*Client) CollectionExists ¶
CollectionExists checks if a collection exists
func (*Client) CreateCollection ¶
func (c *Client) CreateCollection(ctx context.Context, name string, schema *vectordb.CollectionSchema) error
CreateCollection creates a new Milvus collection with explicit schema
func (*Client) DeleteCollection ¶
DeleteCollection deletes a collection and all its documents
func (*Client) DeleteDocument ¶
DeleteDocument deletes a document by ID
func (*Client) DeleteDocuments ¶
func (c *Client) DeleteDocuments(ctx context.Context, collectionName string, documentIDs []string) error
DeleteDocuments deletes multiple documents by IDs
func (*Client) DeleteDocumentsByMetadata ¶
func (c *Client) DeleteDocumentsByMetadata(ctx context.Context, collectionName string, metadata map[string]interface{}) error
DeleteDocumentsByMetadata deletes documents matching metadata criteria
func (*Client) GetCollectionCount ¶
GetCollectionCount returns the number of documents in a collection
func (*Client) GetDocument ¶
func (c *Client) GetDocument(ctx context.Context, collectionName, documentID string) (*vectordb.Document, error)
GetDocument retrieves a document by ID
func (*Client) ListCollections ¶
ListCollections returns a list of all collections
func (*Client) ListDocuments ¶
func (c *Client) ListDocuments(ctx context.Context, collectionName string, limit, offset int) ([]*vectordb.Document, error)
ListDocuments returns a paginated list of documents from a collection
func (*Client) SearchBM25 ¶
func (c *Client) SearchBM25(ctx context.Context, collectionName, query string, opts *vectordb.QueryOptions) ([]*vectordb.QueryResult, error)
SearchBM25 performs keyword-based search using Milvus BM25 (Milvus 2.4+)
func (*Client) SearchByMetadata ¶
func (c *Client) SearchByMetadata(ctx context.Context, collectionName string, metadata map[string]interface{}, opts *vectordb.QueryOptions) ([]*vectordb.QueryResult, error)
SearchByMetadata searches documents by metadata fields
type Config ¶
type Config struct {
// Connection settings
Address string // Milvus server address (e.g., "localhost:19530")
Username string // Username for authentication (optional)
Password string // Password for authentication (optional)
APIKey string // API key/token for Zilliz Cloud (optional)
Database string // Database name (default: "default")
Timeout int // Timeout in seconds for operations (default: 10)
// Vector search settings
VectorDimensions int // Embedding vector dimensions (e.g., 1536 for OpenAI)
SimilarityMetric string // Similarity metric: "L2", "IP" (inner product), or "COSINE"
}
Config holds Milvus client configuration
type Factory ¶
type Factory struct{}
Factory implements the ClientFactory interface for Milvus
func (*Factory) CreateClient ¶
CreateClient creates a new Milvus client
func (*Factory) GetSupportedTypes ¶
func (f *Factory) GetSupportedTypes() []vectordb.VectorDBType
GetSupportedTypes returns the list of supported database types