Documentation
¶
Overview ¶
Package vectordb contains vectordb interface and different engines like memory, chromem and milvus implementations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type EngineType ¶
type EngineType string
const ( Memory EngineType = "memory" Chromem EngineType = "chromem" Milvus EngineType = "milvus" )
type Option ¶
type Option func(*Options)
Option is a function type for configuring VectorDB instances. It follows the functional options pattern for clean and flexible configuration.
func WithColumns ¶
WithColumns specifies which columns to retrieve from the database. This can optimize performance by only fetching needed fields.
Example:
retriever, err := NewRetriever(
WithColumns("Text", "Metadata", "Source"),
)
func WithDimension ¶
WithDimension sets the dimension of vectors to be stored. This must match the dimension of your embedding model: - text-embedding-3-small: 1536 - text-embedding-ada-002: 1536 - Cohere embed-multilingual-v3.0: 1024
func WithEngine ¶
func WithEngine(engine EngineType) Option
WithEngineType sets the database type. Supported types: - "milvus": Production-grade vector database - "memory": In-memory database for testing - "chromem": Chrome-based persistent storage
func WithHybrid ¶
WithHybrid enables or disables hybrid search. Hybrid search combines vector similarity with keyword matching.
Example:
retriever, err := NewRetriever(
WithHybrid(true), // Enable hybrid search
)
func WithMinScore ¶
WithMinScore sets the minimum similarity score threshold. Results with scores below this threshold will be filtered out.
Example:
retriever, err := NewRetriever(
WithMinScore(0.8), // Only return high-confidence matches
)
type Options ¶
type Options struct {
EngineType EngineType // Database type (e.g., "milvus", "memory")
TopK int // Maximum number of results to return
MinScore float64 // Minimum similarity score threshold
UseHybrid bool // Enable hybrid search (vector + keyword)
Columns []string // Columns to retrieve from the database
Dimension int // Vector dimension
}
type Record ¶
type Record struct {
// ID is the identifier for the result
ID string
// Score is the similarity score for the result
Score float64
// Embedding embeddings for doc
Embedding embedder.Embedding
}
Record represents a single result from a vector similarity search.
type SearchOption ¶
type SearchOption func(*SearchOptions)
func SearchWithCollection ¶
func SearchWithCollection(name string) SearchOption
func SearchWithExclude ¶
func SearchWithExclude(v string) SearchOption
func SearchWithInclude ¶
func SearchWithInclude(v string) SearchOption
func SearchWithMeta ¶
func SearchWithMeta(meta map[string]string) SearchOption
func SearchWithTopK ¶
func SearchWithTopK(topK int) SearchOption