Documentation
¶
Overview ¶
Package vector provides a unified interface for vector database operations.
This package abstracts vector storage and similarity search, allowing different backends (chromem-go, Qdrant, Chroma, etc.) to be used interchangeably. It serves as the foundation for both:
- Long-term memory (session/conversation search)
- RAG (document retrieval)
Architecture (ported from legacy pkg/databases) ¶
The package follows a provider pattern:
┌─────────────────────────────────────────────────────────────────────┐ │ Provider Interface │ │ • Upsert, Search, Delete operations │ │ • Collection management │ │ • Metadata filtering │ ├─────────────────────────────────────────────────────────────────────┤ │ Implementations │ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │ │ │ ChromemProv │ │ QdrantProv │ │ ChromaProv │ │ PineconePr │ │ │ │ (embedded) │ │ (external) │ │ (external) │ │ (cloud) │ │ │ └─────────────┘ └─────────────┘ └─────────────┘ └─────────────┘ │ └─────────────────────────────────────────────────────────────────────┘
Usage ¶
The typical flow is:
- Create a provider from configuration
- Use with SearchEngine (rag/search) for high-level operations
- SearchEngine handles embedding generation and query processing
Example:
provider, _ := vector.NewChromemProvider(vector.ChromemConfig{
PersistPath: ".hector/vectors",
})
defer provider.Close()
// Upsert with pre-computed vector
provider.Upsert(ctx, "documents", "doc1", embedding, metadata)
// Search with query vector
results, _ := provider.Search(ctx, "documents", queryVector, 10)
Index ¶
- type ChromaConfig
- type ChromaProvider
- func (p *ChromaProvider) Close() error
- func (p *ChromaProvider) Count(ctx context.Context, collection string) (int, error)
- func (p *ChromaProvider) CreateCollection(ctx context.Context, collection string, vectorDimension int) error
- func (p *ChromaProvider) Delete(ctx context.Context, collection string, id string) error
- func (p *ChromaProvider) DeleteApp(ctx context.Context, appID string) error
- func (p *ChromaProvider) DeleteByFilter(ctx context.Context, collection string, filter map[string]any) error
- func (p *ChromaProvider) DeleteCollection(ctx context.Context, collection string) error
- func (p *ChromaProvider) Name() string
- func (p *ChromaProvider) Search(ctx context.Context, collection string, vector []float32, topK int) ([]Result, error)
- func (p *ChromaProvider) SearchWithFilter(ctx context.Context, collection string, vector []float32, topK int, ...) ([]Result, error)
- func (p *ChromaProvider) Upsert(ctx context.Context, collection string, id string, vector []float32, ...) error
- type ChromemConfig
- type ChromemProvider
- func (p *ChromemProvider) Close() error
- func (p *ChromemProvider) Count(ctx context.Context, collection string) (int, error)
- func (p *ChromemProvider) CreateCollection(ctx context.Context, collection string, vectorDimension int) error
- func (p *ChromemProvider) Delete(ctx context.Context, collection string, id string) error
- func (p *ChromemProvider) DeleteApp(ctx context.Context, appID string) error
- func (p *ChromemProvider) DeleteByFilter(ctx context.Context, collection string, filter map[string]any) error
- func (p *ChromemProvider) DeleteCollection(ctx context.Context, collection string) error
- func (p *ChromemProvider) Name() string
- func (p *ChromemProvider) Search(ctx context.Context, collection string, vector []float32, topK int) ([]Result, error)
- func (p *ChromemProvider) SearchWithFilter(ctx context.Context, collection string, vector []float32, topK int, ...) ([]Result, error)
- func (p *ChromemProvider) Upsert(ctx context.Context, collection string, id string, vector []float32, ...) error
- type Config
- type MilvusConfig
- type MilvusProvider
- func (p *MilvusProvider) Close() error
- func (p *MilvusProvider) Count(ctx context.Context, collection string) (int, error)
- func (p *MilvusProvider) CreateCollection(ctx context.Context, collection string, vectorDimension int) error
- func (p *MilvusProvider) Delete(ctx context.Context, collection string, id string) error
- func (p *MilvusProvider) DeleteApp(ctx context.Context, appID string) error
- func (p *MilvusProvider) DeleteByFilter(ctx context.Context, collection string, filter map[string]any) error
- func (p *MilvusProvider) DeleteCollection(ctx context.Context, collection string) error
- func (p *MilvusProvider) Name() string
- func (p *MilvusProvider) Search(ctx context.Context, collection string, vector []float32, topK int) ([]Result, error)
- func (p *MilvusProvider) SearchWithFilter(ctx context.Context, collection string, vector []float32, topK int, ...) ([]Result, error)
- func (p *MilvusProvider) Upsert(ctx context.Context, collection string, id string, vector []float32, ...) error
- type NilProvider
- func (NilProvider) Close() error
- func (NilProvider) Count(ctx context.Context, collection string) (int, error)
- func (NilProvider) CreateCollection(ctx context.Context, collection string, vectorDimension int) error
- func (NilProvider) Delete(ctx context.Context, collection string, id string) error
- func (NilProvider) DeleteApp(ctx context.Context, appID string) error
- func (NilProvider) DeleteByFilter(ctx context.Context, collection string, filter map[string]any) error
- func (NilProvider) DeleteCollection(ctx context.Context, collection string) error
- func (NilProvider) Name() string
- func (NilProvider) Search(ctx context.Context, collection string, vector []float32, topK int) ([]Result, error)
- func (NilProvider) SearchWithFilter(ctx context.Context, collection string, vector []float32, topK int, ...) ([]Result, error)
- func (NilProvider) Upsert(ctx context.Context, collection string, id string, vector []float32, ...) error
- type PineconeConfig
- type PineconeProvider
- func (p *PineconeProvider) Close() error
- func (p *PineconeProvider) Count(ctx context.Context, collection string) (int, error)
- func (p *PineconeProvider) CreateCollection(ctx context.Context, collection string, vectorDimension int) error
- func (p *PineconeProvider) Delete(ctx context.Context, collection string, id string) error
- func (p *PineconeProvider) DeleteApp(ctx context.Context, appID string) error
- func (p *PineconeProvider) DeleteByFilter(ctx context.Context, collection string, filter map[string]any) error
- func (p *PineconeProvider) DeleteCollection(ctx context.Context, collection string) error
- func (p *PineconeProvider) Name() string
- func (p *PineconeProvider) Search(ctx context.Context, collection string, vector []float32, topK int) ([]Result, error)
- func (p *PineconeProvider) SearchWithFilter(ctx context.Context, collection string, vector []float32, topK int, ...) ([]Result, error)
- func (p *PineconeProvider) Upsert(ctx context.Context, collection string, id string, vector []float32, ...) error
- type Provider
- type ProviderConfig
- type ProviderType
- type QdrantConfig
- type QdrantProvider
- func (p *QdrantProvider) Close() error
- func (p *QdrantProvider) Count(ctx context.Context, collection string) (int, error)
- func (p *QdrantProvider) CreateCollection(ctx context.Context, collection string, vectorDimension int) error
- func (p *QdrantProvider) Delete(ctx context.Context, collection string, id string) error
- func (p *QdrantProvider) DeleteApp(ctx context.Context, appID string) error
- func (p *QdrantProvider) DeleteByFilter(ctx context.Context, collection string, filter map[string]any) error
- func (p *QdrantProvider) DeleteCollection(ctx context.Context, collection string) error
- func (p *QdrantProvider) Name() string
- func (p *QdrantProvider) Search(ctx context.Context, collection string, vector []float32, topK int) ([]Result, error)
- func (p *QdrantProvider) SearchWithFilter(ctx context.Context, collection string, vector []float32, topK int, ...) ([]Result, error)
- func (p *QdrantProvider) Upsert(ctx context.Context, collection string, id string, vector []float32, ...) error
- type Registry
- type Result
- type WeaviateConfig
- type WeaviateProvider
- func (p *WeaviateProvider) Close() error
- func (p *WeaviateProvider) Count(ctx context.Context, collection string) (int, error)
- func (p *WeaviateProvider) CreateCollection(ctx context.Context, collection string, vectorDimension int) error
- func (p *WeaviateProvider) Delete(ctx context.Context, collection string, id string) error
- func (p *WeaviateProvider) DeleteApp(ctx context.Context, appID string) error
- func (p *WeaviateProvider) DeleteByFilter(ctx context.Context, collection string, filter map[string]any) error
- func (p *WeaviateProvider) DeleteCollection(ctx context.Context, collection string) error
- func (p *WeaviateProvider) Name() string
- func (p *WeaviateProvider) Search(ctx context.Context, collection string, vector []float32, topK int) ([]Result, error)
- func (p *WeaviateProvider) SearchWithFilter(ctx context.Context, collection string, vector []float32, topK int, ...) ([]Result, error)
- func (p *WeaviateProvider) Upsert(ctx context.Context, collection string, id string, vector []float32, ...) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChromaConfig ¶
type ChromaConfig struct {
// Host is the Chroma server hostname.
Host string `yaml:"host"`
// Port is the Chroma HTTP port (default: 8000).
Port int `yaml:"port,omitempty"`
// APIKey for authenticated access (optional).
APIKey string `yaml:"api_key,omitempty"`
// UseTLS enables HTTPS connections.
UseTLS bool `yaml:"use_tls,omitempty"`
}
ChromaConfig configures the Chroma vector provider.
Direct port from legacy pkg/databases/chroma.go
type ChromaProvider ¶
type ChromaProvider struct {
// contains filtered or unexported fields
}
ChromaProvider implements Provider using Chroma vector database.
Direct port from legacy pkg/databases/chroma.go
func NewChromaProvider ¶
func NewChromaProvider(cfg ChromaConfig) (*ChromaProvider, error)
NewChromaProvider creates a new Chroma provider.
func (*ChromaProvider) Count ¶ added in v1.21.0
Count returns the number of documents in a collection. Note: Returns 0 as counting would require an additional API call.
func (*ChromaProvider) CreateCollection ¶
func (p *ChromaProvider) CreateCollection(ctx context.Context, collection string, vectorDimension int) error
CreateCollection creates a new collection in Chroma.
func (*ChromaProvider) DeleteApp ¶ added in v1.21.0
func (p *ChromaProvider) DeleteApp(ctx context.Context, appID string) error
DeleteApp cleans up all resources associated with an app.
func (*ChromaProvider) DeleteByFilter ¶
func (p *ChromaProvider) DeleteByFilter(ctx context.Context, collection string, filter map[string]any) error
DeleteByFilter removes all documents matching the filter.
func (*ChromaProvider) DeleteCollection ¶
func (p *ChromaProvider) DeleteCollection(ctx context.Context, collection string) error
DeleteCollection removes a collection from Chroma.
func (*ChromaProvider) Name ¶
func (p *ChromaProvider) Name() string
Name returns the provider name.
func (*ChromaProvider) Search ¶
func (p *ChromaProvider) Search(ctx context.Context, collection string, vector []float32, topK int) ([]Result, error)
Search finds the most similar vectors.
type ChromemConfig ¶
type ChromemConfig struct {
// PersistPath for file persistence (optional).
// If empty, vectors are stored in memory only.
// Directory will be created if it doesn't exist.
PersistPath string `yaml:"persist_path,omitempty"`
// Compress enables gzip compression for persistence.
// Reduces file size but increases CPU usage.
Compress bool `yaml:"compress,omitempty"`
}
ChromemConfig configures the chromem provider.
type ChromemProvider ¶
type ChromemProvider struct {
// contains filtered or unexported fields
}
ChromemProvider implements Provider using chromem-go for embedded vector storage.
This is the recommended provider for zero-config deployments as it requires no external services. It stores vectors in memory with optional file persistence.
Features:
- Pure Go, no external dependencies
- Optional file persistence (gzip compressed)
- Cosine similarity search
- Metadata filtering
- Multi-tenant support via app-specific directories
Limitations:
- Single-process only (no distributed search)
- Memory-bound (all vectors in RAM)
- No hybrid search support
For production at scale, consider Qdrant or other external providers.
func NewChromemProvider ¶
func NewChromemProvider(cfg ChromemConfig) (*ChromemProvider, error)
NewChromemProvider creates a new chromem-based vector provider.
func (*ChromemProvider) Close ¶
func (p *ChromemProvider) Close() error
Close persists the database and releases resources.
func (*ChromemProvider) Count ¶ added in v1.21.0
Count returns the number of documents in a collection.
func (*ChromemProvider) CreateCollection ¶
func (p *ChromemProvider) CreateCollection(ctx context.Context, collection string, vectorDimension int) error
CreateCollection creates a new collection. chromem-go creates collections implicitly, so this is a no-op.
func (*ChromemProvider) DeleteApp ¶ added in v1.21.0
func (p *ChromemProvider) DeleteApp(ctx context.Context, appID string) error
DeleteApp cleans up all resources associated with an app.
func (*ChromemProvider) DeleteByFilter ¶
func (p *ChromemProvider) DeleteByFilter(ctx context.Context, collection string, filter map[string]any) error
DeleteByFilter removes all documents matching the filter.
func (*ChromemProvider) DeleteCollection ¶
func (p *ChromemProvider) DeleteCollection(ctx context.Context, collection string) error
DeleteCollection removes a collection and all its documents. NOTE: For app isolation logic, this removes the collection FROM the app-specific DB.
func (*ChromemProvider) Name ¶
func (p *ChromemProvider) Name() string
Name returns the provider name.
func (*ChromemProvider) Search ¶
func (p *ChromemProvider) Search(ctx context.Context, collection string, vector []float32, topK int) ([]Result, error)
Search finds the most similar vectors in a collection.
type Config ¶
type Config struct {
// Type identifies the provider implementation.
// Values: "chromem", "qdrant", "chroma", "pinecone", "milvus", "weaviate"
Type string `yaml:"type"`
// Collection is the default collection name.
// Individual operations can override this.
Collection string `yaml:"collection,omitempty"`
}
Config is the base configuration for all vector providers.
type MilvusConfig ¶
type MilvusConfig struct {
// Host is the Milvus server hostname.
Host string `yaml:"host"`
// Port is the Milvus HTTP port (default: 19530).
Port int `yaml:"port,omitempty"`
// APIKey for authenticated access (optional).
APIKey string `yaml:"api_key,omitempty"`
// UseTLS enables HTTPS connections.
UseTLS bool `yaml:"use_tls,omitempty"`
}
MilvusConfig configures the Milvus vector provider.
Direct port from legacy pkg/databases/milvus.go
type MilvusProvider ¶
type MilvusProvider struct {
// contains filtered or unexported fields
}
MilvusProvider implements Provider using Milvus vector database.
Direct port from legacy pkg/databases/milvus.go
func NewMilvusProvider ¶
func NewMilvusProvider(cfg MilvusConfig) (*MilvusProvider, error)
NewMilvusProvider creates a new Milvus provider.
func (*MilvusProvider) Count ¶ added in v1.21.0
Count returns the number of documents in a collection. Note: Returns 0 as counting would require an additional API call.
func (*MilvusProvider) CreateCollection ¶
func (p *MilvusProvider) CreateCollection(ctx context.Context, collection string, vectorDimension int) error
CreateCollection creates a new collection in Milvus.
func (*MilvusProvider) DeleteApp ¶ added in v1.21.0
func (p *MilvusProvider) DeleteApp(ctx context.Context, appID string) error
DeleteApp cleans up all resources associated with an app.
func (*MilvusProvider) DeleteByFilter ¶
func (p *MilvusProvider) DeleteByFilter(ctx context.Context, collection string, filter map[string]any) error
DeleteByFilter removes all documents matching the filter.
func (*MilvusProvider) DeleteCollection ¶
func (p *MilvusProvider) DeleteCollection(ctx context.Context, collection string) error
DeleteCollection removes a collection from Milvus.
func (*MilvusProvider) Name ¶
func (p *MilvusProvider) Name() string
Name returns the provider name.
func (*MilvusProvider) Search ¶
func (p *MilvusProvider) Search(ctx context.Context, collection string, vector []float32, topK int) ([]Result, error)
Search finds the most similar vectors.
type NilProvider ¶
type NilProvider struct{}
NilProvider is a no-op implementation for when vector search is disabled.
func (NilProvider) Close ¶
func (NilProvider) Close() error
func (NilProvider) CreateCollection ¶
func (NilProvider) DeleteApp ¶ added in v1.21.0
func (NilProvider) DeleteApp(ctx context.Context, appID string) error
func (NilProvider) DeleteByFilter ¶
func (NilProvider) DeleteCollection ¶
func (NilProvider) DeleteCollection(ctx context.Context, collection string) error
func (NilProvider) Name ¶
func (NilProvider) Name() string
func (NilProvider) SearchWithFilter ¶
type PineconeConfig ¶
type PineconeConfig struct {
// APIKey is required for Pinecone authentication.
APIKey string `yaml:"api_key"`
// Host is the Pinecone API host (optional, defaults to https://api.pinecone.io).
Host string `yaml:"host,omitempty"`
// IndexName is the default index to use.
IndexName string `yaml:"index_name"`
// Environment is the Pinecone environment (e.g., "us-west1-gcp").
Environment string `yaml:"environment,omitempty"`
}
PineconeConfig configures the Pinecone vector provider.
Direct port from legacy pkg/databases/pinecone.go
type PineconeProvider ¶
type PineconeProvider struct {
// contains filtered or unexported fields
}
PineconeProvider implements Provider using Pinecone vector database.
Direct port from legacy pkg/databases/pinecone.go
func NewPineconeProvider ¶
func NewPineconeProvider(cfg PineconeConfig) (*PineconeProvider, error)
NewPineconeProvider creates a new Pinecone provider.
func (*PineconeProvider) Close ¶
func (p *PineconeProvider) Close() error
Close closes the Pinecone client.
func (*PineconeProvider) Count ¶ added in v1.21.0
Count returns the number of documents in a collection. Note: Returns 0 as Pinecone doesn't provide a simple count API.
func (*PineconeProvider) CreateCollection ¶
func (p *PineconeProvider) CreateCollection(ctx context.Context, collection string, vectorDimension int) error
CreateCollection checks if the index exists (Pinecone indexes must be created separately).
func (*PineconeProvider) DeleteApp ¶ added in v1.21.0
func (p *PineconeProvider) DeleteApp(ctx context.Context, appID string) error
DeleteApp cleans up all resources associated with an app.
func (*PineconeProvider) DeleteByFilter ¶
func (p *PineconeProvider) DeleteByFilter(ctx context.Context, collection string, filter map[string]any) error
DeleteByFilter removes all documents matching the filter.
func (*PineconeProvider) DeleteCollection ¶
func (p *PineconeProvider) DeleteCollection(ctx context.Context, collection string) error
DeleteCollection returns an error (Pinecone index deletion requires API).
func (*PineconeProvider) Name ¶
func (p *PineconeProvider) Name() string
Name returns the provider name.
func (*PineconeProvider) Search ¶
func (p *PineconeProvider) Search(ctx context.Context, collection string, vector []float32, topK int) ([]Result, error)
Search finds the most similar vectors.
type Provider ¶
type Provider interface {
// Upsert adds or updates a document with its vector embedding.
//
// If a document with the same ID exists, it will be updated.
// The vector dimension must match the collection's configured dimension.
//
// Parameters:
// - collection: logical grouping (e.g., "memory", "documents")
// - id: unique document identifier
// - vector: embedding vector from the embedder
// - metadata: additional searchable/filterable attributes
Upsert(ctx context.Context, collection string, id string, vector []float32, metadata map[string]any) error
// Search finds the most similar vectors in a collection.
//
// Returns results ordered by similarity score (highest first).
// The query vector should be generated by the same embedder
// used for indexing.
//
// Parameters:
// - collection: which collection to search
// - vector: query embedding vector
// - topK: maximum number of results to return
Search(ctx context.Context, collection string, vector []float32, topK int) ([]Result, error)
// SearchWithFilter combines vector similarity with metadata filtering.
//
// The filter map supports equality matching on metadata fields.
// Filter semantics:
// - {"field": "value"} - exact match
// - {"field1": "v1", "field2": "v2"} - AND of all conditions
//
// Example:
// filter := map[string]any{"user_id": "user123", "type": "document"}
SearchWithFilter(ctx context.Context, collection string, vector []float32, topK int, filter map[string]any) ([]Result, error)
// Delete removes a document from a collection by ID.
Delete(ctx context.Context, collection string, id string) error
// DeleteByFilter removes all documents matching the filter.
//
// Use with caution - this can delete many documents at once.
DeleteByFilter(ctx context.Context, collection string, filter map[string]any) error
// CreateCollection creates a new collection with specified vector dimension.
//
// Some backends create collections implicitly on first Upsert.
// This method allows explicit creation with configuration.
CreateCollection(ctx context.Context, collection string, vectorDimension int) error
// DeleteCollection removes a collection and all its documents.
DeleteCollection(ctx context.Context, collection string) error
// Count returns the number of documents in a collection.
// Returns 0 if the collection doesn't exist.
Count(ctx context.Context, collection string) (int, error)
// DeleteApp cleans up all resources associated with an app.
// For embedded providers, this might close DB connections.
// For external providers, this might drop all collections for the app.
DeleteApp(ctx context.Context, appID string) error
// Name returns the provider implementation name (e.g., "chromem", "qdrant").
Name() string
// Close releases resources held by the provider.
// Should be called when the provider is no longer needed.
io.Closer
}
Provider defines the interface for vector database operations.
All implementations must be thread-safe for concurrent access. Vector dimensions are determined by the embedder used and should be consistent within a collection.
Derived from legacy pkg/databases/registry.go:DatabaseProvider
func NewProvider ¶
func NewProvider(cfg *ProviderConfig) (Provider, error)
NewProvider creates a vector provider from configuration.
type ProviderConfig ¶
type ProviderConfig struct {
// Type identifies which provider to create.
Type ProviderType `yaml:"type"`
// Chromem configuration (used when Type == "chromem").
Chromem *ChromemConfig `yaml:"chromem,omitempty"`
// Qdrant configuration (used when Type == "qdrant").
Qdrant *QdrantConfig `yaml:"qdrant,omitempty"`
// Pinecone configuration (used when Type == "pinecone").
Pinecone *PineconeConfig `yaml:"pinecone,omitempty"`
// Weaviate configuration (used when Type == "weaviate").
Weaviate *WeaviateConfig `yaml:"weaviate,omitempty"`
// Milvus configuration (used when Type == "milvus").
Milvus *MilvusConfig `yaml:"milvus,omitempty"`
// Chroma configuration (used when Type == "chroma").
Chroma *ChromaConfig `yaml:"chroma,omitempty"`
}
ProviderConfig is the configuration for creating vector providers.
func (*ProviderConfig) SetDefaults ¶
func (c *ProviderConfig) SetDefaults()
SetDefaults applies default values.
func (*ProviderConfig) Validate ¶
func (c *ProviderConfig) Validate() error
Validate checks the configuration.
type ProviderType ¶
type ProviderType string
ProviderType identifies a vector provider implementation.
const ( // ProviderChromem uses chromem-go for embedded vector storage. // Zero-config, no external dependencies. Best for development and small deployments. ProviderChromem ProviderType = "chromem" // ProviderQdrant uses Qdrant vector database. // High-performance, supports distributed deployments. ProviderQdrant ProviderType = "qdrant" // ProviderChroma uses Chroma vector database. // Python-native but has Go client support. ProviderChroma ProviderType = "chroma" // ProviderPinecone uses Pinecone managed vector database. // Fully managed cloud service. ProviderPinecone ProviderType = "pinecone" // ProviderMilvus uses Milvus vector database. // Open-source, supports large-scale deployments. ProviderMilvus ProviderType = "milvus" // ProviderWeaviate uses Weaviate vector database. // Supports GraphQL queries and hybrid search. ProviderWeaviate ProviderType = "weaviate" )
type QdrantConfig ¶
type QdrantConfig struct {
// Host is the Qdrant server hostname.
Host string `yaml:"host"`
// Port is the Qdrant gRPC port (default: 6334).
Port int `yaml:"port"`
// APIKey for authenticated access (optional).
APIKey string `yaml:"api_key,omitempty"`
// UseTLS enables TLS connections.
UseTLS bool `yaml:"use_tls,omitempty"`
}
QdrantConfig configures the Qdrant vector provider.
Direct port from legacy pkg/databases/qdrant.go
type QdrantProvider ¶
type QdrantProvider struct {
// contains filtered or unexported fields
}
QdrantProvider implements Provider using Qdrant vector database.
Direct port from legacy pkg/databases/qdrant.go
func NewQdrantProvider ¶
func NewQdrantProvider(cfg QdrantConfig) (*QdrantProvider, error)
NewQdrantProvider creates a new Qdrant provider.
func (*QdrantProvider) Close ¶
func (p *QdrantProvider) Close() error
Close closes the Qdrant client.
func (*QdrantProvider) Count ¶ added in v1.21.0
Count returns the number of documents in a collection. Note: Requires additional API call, returns 0 for performance.
func (*QdrantProvider) CreateCollection ¶
func (p *QdrantProvider) CreateCollection(ctx context.Context, collection string, vectorDimension int) error
CreateCollection creates a new collection.
func (*QdrantProvider) DeleteApp ¶ added in v1.21.0
func (p *QdrantProvider) DeleteApp(ctx context.Context, appID string) error
DeleteApp cleans up app-specific resources.
func (*QdrantProvider) DeleteByFilter ¶
func (p *QdrantProvider) DeleteByFilter(ctx context.Context, collection string, filter map[string]any) error
DeleteByFilter removes all documents matching the filter.
func (*QdrantProvider) DeleteCollection ¶
func (p *QdrantProvider) DeleteCollection(ctx context.Context, collection string) error
DeleteCollection removes a collection.
func (*QdrantProvider) Name ¶
func (p *QdrantProvider) Name() string
Name returns the provider name.
func (*QdrantProvider) Search ¶
func (p *QdrantProvider) Search(ctx context.Context, collection string, vector []float32, topK int) ([]Result, error)
Search finds the most similar vectors.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages named vector providers.
This allows multiple providers to be configured and accessed by name, similar to how databases or embedders are managed.
type Result ¶
type Result struct {
// ID is the unique document identifier.
ID string
// Score represents similarity/relevance (higher is better).
Score float32
// Content is the original text content (if stored in metadata).
Content string
// Vector is the document's embedding (optional, not always returned).
Vector []float32
// Metadata contains the document's metadata fields.
Metadata map[string]any
}
Result represents a single search result.
Results are returned ordered by Score (highest first). The Score semantics depend on the implementation:
- Cosine similarity: 0.0 to 1.0 (1.0 = identical)
- Euclidean distance: inverted (higher = more similar)
type WeaviateConfig ¶
type WeaviateConfig struct {
// Host is the Weaviate server hostname.
Host string `yaml:"host"`
// Port is the Weaviate HTTP port (default: 8080).
Port int `yaml:"port,omitempty"`
// APIKey for authenticated access (optional).
APIKey string `yaml:"api_key,omitempty"`
// UseTLS enables HTTPS connections.
UseTLS bool `yaml:"use_tls,omitempty"`
}
WeaviateConfig configures the Weaviate vector provider.
Direct port from legacy pkg/databases/weaviate.go
type WeaviateProvider ¶
type WeaviateProvider struct {
// contains filtered or unexported fields
}
WeaviateProvider implements Provider using Weaviate vector database.
Direct port from legacy pkg/databases/weaviate.go
func NewWeaviateProvider ¶
func NewWeaviateProvider(cfg WeaviateConfig) (*WeaviateProvider, error)
NewWeaviateProvider creates a new Weaviate provider.
func (*WeaviateProvider) Close ¶
func (p *WeaviateProvider) Close() error
Close closes the HTTP client.
func (*WeaviateProvider) Count ¶ added in v1.21.0
Count returns the number of documents in a collection. Note: Returns 0 as counting would require an aggregate query.
func (*WeaviateProvider) CreateCollection ¶
func (p *WeaviateProvider) CreateCollection(ctx context.Context, collection string, vectorDimension int) error
CreateCollection creates a new class in Weaviate.
func (*WeaviateProvider) DeleteApp ¶ added in v1.21.0
func (p *WeaviateProvider) DeleteApp(ctx context.Context, appID string) error
DeleteApp cleans up all resources associated with an app.
func (*WeaviateProvider) DeleteByFilter ¶
func (p *WeaviateProvider) DeleteByFilter(ctx context.Context, collection string, filter map[string]any) error
DeleteByFilter removes all documents matching the filter.
func (*WeaviateProvider) DeleteCollection ¶
func (p *WeaviateProvider) DeleteCollection(ctx context.Context, collection string) error
DeleteCollection removes a class from Weaviate.
func (*WeaviateProvider) Name ¶
func (p *WeaviateProvider) Name() string
Name returns the provider name.
func (*WeaviateProvider) Search ¶
func (p *WeaviateProvider) Search(ctx context.Context, collection string, vector []float32, topK int) ([]Result, error)
Search finds the most similar vectors.