search

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ProbeFTS5

func ProbeFTS5(db *sql.DB) bool

ProbeFTS5 tests whether the SQLite connection supports FTS5. It creates a temporary FTS5 table and immediately drops it. Returns true if FTS5 is available, false otherwise.

Types

type FTS5Index

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

FTS5Index manages an FTS5 virtual table for full-text search. It is domain-agnostic — it operates on raw table names, column names, rowids, and string values. Domain semantics (e.g., which entries to index) are the caller's responsibility.

func NewFTS5Index

func NewFTS5Index(db *sql.DB, tableName string, columns []string) *FTS5Index

NewFTS5Index creates a new FTS5Index. Call EnsureTable() before use.

func (*FTS5Index) BulkInsert

func (idx *FTS5Index) BulkInsert(ctx context.Context, records []Record) error

BulkInsert inserts multiple records in a single transaction.

func (*FTS5Index) Delete

func (idx *FTS5Index) Delete(ctx context.Context, rowid string) error

Delete removes a record by rowid.

func (*FTS5Index) DropTable

func (idx *FTS5Index) DropTable() error

DropTable drops the FTS5 virtual table if it exists.

func (*FTS5Index) EnsureTable

func (idx *FTS5Index) EnsureTable() error

EnsureTable creates the FTS5 virtual table if it does not exist. The table includes an UNINDEXED source_id column for row identification that is not included in FTS5 text search.

func (*FTS5Index) Insert

func (idx *FTS5Index) Insert(ctx context.Context, rowid string, values []string) error

Insert adds a new record to the FTS5 index. The rowid is a string identifier (typically the source entity's key). values must match the column order from NewFTS5Index.

func (*FTS5Index) Search

func (idx *FTS5Index) Search(ctx context.Context, query string, limit int) ([]SearchResult, error)

Search executes an FTS5 MATCH query and returns results ranked by BM25. Supports plain keywords, phrase queries (quoted), and prefix queries (trailing *). Returns an empty slice for empty queries.

func (*FTS5Index) Update

func (idx *FTS5Index) Update(ctx context.Context, rowid string, values []string) error

Update replaces an existing record by deleting and re-inserting.

type Record

type Record struct {
	RowID  string
	Values []string
}

Record holds data for a single FTS5 record to insert.

type SearchResult

type SearchResult struct {
	RowID string
	Rank  float64
}

SearchResult holds a single FTS5 search result.

Jump to

Keyboard shortcuts

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