postgres

package
v2.5.1 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PGVector

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

func NewPGVector

func NewPGVector(db *sqlx.DB, config PGVectorConfig) (*PGVector, error)

func (*PGVector) Clear

func (pv *PGVector) Clear(ctx context.Context) error

func (*PGVector) Delete

func (pv *PGVector) Delete(ctx context.Context, postIDs []string) error

func (*PGVector) DeleteOrphaned

func (pv *PGVector) DeleteOrphaned(ctx context.Context, nowTime, batchSize int64) (int64, error)

DeleteOrphaned removes embeddings whose posts no longer exist or are soft-deleted past retention.

func (*PGVector) FinalizeBulkIndex

func (pv *PGVector) FinalizeBulkIndex(ctx context.Context) error

FinalizeBulkIndex rebuilds the ANN index (same DDL as the constructor). Drops a same-named wrong/invalid leftover first so IF NOT EXISTS cannot keep it. Uses a pinned connection with statement_timeout=0; querying via pv.db while holding it would self-deadlock on a one-conn pool.

func (*PGVector) PrepareBulkIndex

func (pv *PGVector) PrepareBulkIndex(ctx context.Context) error

PrepareBulkIndex drops the ANN index for bulk load. Keeps post_id B-tree (needed by catch-up's NOT EXISTS).

func (*PGVector) Search

func (pv *PGVector) Search(ctx context.Context, embedding []float32, opts embeddings.SearchOptions) ([]embeddings.SearchResult, error)

func (*PGVector) Store

func (pv *PGVector) Store(ctx context.Context, docs []embeddings.PostDocument, embeddings [][]float32) error

func (*PGVector) VectorIndexExists

func (pv *PGVector) VectorIndexExists(ctx context.Context) (bool, error)

VectorIndexExists is true only for a valid index with the expected definition.

type PGVectorConfig

type PGVectorConfig struct {
	Dimensions int `json:"dimensions"`

	// SkipVectorIndex: skip constructor CREATE while a deferred reindex owns
	// the lifecycle (avoids sync rebuild of an intentionally dropped index).
	SkipVectorIndex bool `json:"-"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL