Documentation
¶
Overview ¶
Package postgres provides a PostgreSQL pgvector-backed Reliquary index.
Index ¶
- type Config
- type Index
- func (i *Index) DeleteDocument(ctx context.Context, documentID string) error
- func (i *Index) Migrate(ctx context.Context) error
- func (i *Index) ReplaceDocuments(ctx context.Context, replacements []indexcontract.DocumentReplacement) error
- func (i *Index) Reset(ctx context.Context) error
- func (i *Index) Search(ctx context.Context, query indexcontract.IndexQuery) ([]*retrieval.Result, error)
- func (i *Index) Upsert(ctx context.Context, items []*retrieval.Result) error
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Table string
}
Config controls PostgreSQL index storage. Migrate must be called explicitly before the index is used.
type Index ¶
type Index struct {
// contains filtered or unexported fields
}
Index stores retrieval candidates in a caller-owned PostgreSQL pool.
func New ¶
New validates configuration without connecting or performing migrations.
Example ¶
package main
import (
"fmt"
"github.com/dotcommander/reliquary/adapter/postgres"
"github.com/jackc/pgx/v5/pgxpool"
)
func main() {
// Construction validates table configuration without database I/O.
pool := &pgxpool.Pool{}
idx, err := postgres.New(pool, postgres.Config{Table: "reliquary_index"})
fmt.Println(idx != nil, err == nil)
}
Output: true true
func (*Index) DeleteDocument ¶
DeleteDocument transactionally removes all results for a document.
func (*Index) Migrate ¶
Migrate idempotently creates retrieval-owned PostgreSQL schema. It is never called implicitly by New or data operations.
func (*Index) ReplaceDocuments ¶ added in v0.9.0
func (i *Index) ReplaceDocuments(ctx context.Context, replacements []indexcontract.DocumentReplacement) error
ReplaceDocuments atomically replaces complete document revisions. The table lock serializes retained-corpus dimension and identity discovery with all other writers.
func (*Index) Search ¶
func (i *Index) Search(ctx context.Context, query indexcontract.IndexQuery) ([]*retrieval.Result, error)
Search retrieves candidates in PostgreSQL and performs final Reliquary scoring. Text-only queries read every filter-matching row before lexical ranking, so their read and memory cost grows with the matching corpus. Vector queries retain the SQL candidate bound.