Documentation
¶
Index ¶
- type Config
- type VectorIndex
- func (v *VectorIndex) Close()
- func (v *VectorIndex) Delete(ctx context.Context, id string) error
- func (v *VectorIndex) DeleteBatch(ctx context.Context, ids []string) error
- func (v *VectorIndex) DeleteByDocument(ctx context.Context, documentID string) error
- func (v *VectorIndex) DeleteByDocuments(ctx context.Context, documentIDs []string) error
- func (v *VectorIndex) DeleteBySourceAndContainer(ctx context.Context, sourceID, containerID string) error
- func (v *VectorIndex) EnsureTable(ctx context.Context) error
- func (v *VectorIndex) HealthCheck(ctx context.Context) error
- func (v *VectorIndex) Index(ctx context.Context, id string, documentID string, embedding []float32) error
- func (v *VectorIndex) IndexBatch(ctx context.Context, ids []string, documentIDs []string, sourceIDs []string, ...) error
- func (v *VectorIndex) Search(ctx context.Context, embedding []float32, k int) ([]string, []float64, error)
- func (v *VectorIndex) SearchWithContent(ctx context.Context, embedding []float32, k int, sourceIDs []string) ([]driven.VectorSearchResult, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// URL is the PostgreSQL connection string with pgvector extension
URL string
// Dimensions is the embedding vector dimension (default: 1536 for OpenAI ada-002)
Dimensions int
// IndexType is the vector index type: "hnsw" or "ivfflat" (default: "hnsw")
IndexType string
// DistanceMetric is the distance function: "cosine", "l2", or "inner_product" (default: "cosine")
DistanceMetric string
// MaxOpenConns is the maximum number of open connections in the pool
MaxOpenConns int32
// MinConns is the minimum number of connections in the pool
MinConns int32
// MaxConnLifetime is the maximum lifetime of a connection
MaxConnLifetime time.Duration
// MaxConnIdleTime is the maximum idle time of a connection
MaxConnIdleTime time.Duration
// ConnTimeout is the connection timeout
ConnTimeout time.Duration
}
Config holds pgvector connection and index configuration
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a configuration with sensible defaults
type VectorIndex ¶
type VectorIndex struct {
// contains filtered or unexported fields
}
VectorIndex implements the driven.VectorIndex interface using pgvector
func New ¶
func New(ctx context.Context, cfg Config) (*VectorIndex, error)
New creates a new pgvector VectorIndex adapter
func (*VectorIndex) Delete ¶
func (v *VectorIndex) Delete(ctx context.Context, id string) error
Delete removes a single embedding by chunk ID
func (*VectorIndex) DeleteBatch ¶
func (v *VectorIndex) DeleteBatch(ctx context.Context, ids []string) error
DeleteBatch removes multiple embeddings by chunk IDs
func (*VectorIndex) DeleteByDocument ¶
func (v *VectorIndex) DeleteByDocument(ctx context.Context, documentID string) error
DeleteByDocument removes all embeddings for a document
func (*VectorIndex) DeleteByDocuments ¶
func (v *VectorIndex) DeleteByDocuments(ctx context.Context, documentIDs []string) error
DeleteByDocuments removes all embeddings for multiple documents in a single operation
func (*VectorIndex) DeleteBySourceAndContainer ¶ added in v0.2.1
func (v *VectorIndex) DeleteBySourceAndContainer(ctx context.Context, sourceID, containerID string) error
DeleteBySourceAndContainer removes all embeddings for a specific container within a source Joins with documents table to filter by container_id from document metadata
func (*VectorIndex) EnsureTable ¶
func (v *VectorIndex) EnsureTable(ctx context.Context) error
EnsureTable creates the embeddings table if it doesn't exist. Called during startup to ensure the table is ready.
func (*VectorIndex) HealthCheck ¶
func (v *VectorIndex) HealthCheck(ctx context.Context) error
HealthCheck verifies the connection and vector extension availability
func (*VectorIndex) Index ¶
func (v *VectorIndex) Index(ctx context.Context, id string, documentID string, embedding []float32) error
Index inserts or updates a single embedding
func (*VectorIndex) IndexBatch ¶
func (v *VectorIndex) IndexBatch(ctx context.Context, ids []string, documentIDs []string, sourceIDs []string, contents []string, embeddings [][]float32) error
IndexBatch inserts or updates multiple embeddings with their chunk content using batch operations
func (*VectorIndex) Search ¶
func (v *VectorIndex) Search(ctx context.Context, embedding []float32, k int) ([]string, []float64, error)
Search finds the k most similar chunks by embedding distance
func (*VectorIndex) SearchWithContent ¶
func (v *VectorIndex) SearchWithContent(ctx context.Context, embedding []float32, k int, sourceIDs []string) ([]driven.VectorSearchResult, error)
SearchWithContent finds similar vectors and returns chunk content alongside IDs/distances. sourceIDs optionally filters results to specific sources (nil or empty = no filter).