sqlite

package
v0.16.1 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package sqlite provides a SQLite-backed Reliquary candidate index.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Table          string
	CandidateLimit int
}

Config controls schema ownership and bounded candidate retrieval.

type Index

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

Index uses caller-owned SQLite connectivity. New performs no database I/O.

func New

func New(db *sql.DB, cfg Config) (*Index, error)
Example
package main

import (
	"context"
	"database/sql"
	"fmt"

	"github.com/dotcommander/reliquary/adapter/sqlite"
	_ "modernc.org/sqlite"
)

func main() {
	db, err := sql.Open("sqlite", ":memory:")
	if err != nil {
		panic(err)
	}
	defer db.Close()
	db.SetMaxOpenConns(1)

	idx, err := sqlite.New(db, sqlite.Config{
		Table:          "reliquary_index",
		CandidateLimit: 50,
	})
	if err != nil {
		panic(err)
	}

	err = idx.Migrate(context.Background())
	fmt.Println(idx != nil, err == nil)
}
Output:
true true

func (*Index) DeleteDocument

func (i *Index) DeleteDocument(ctx context.Context, documentID string) error

func (*Index) Migrate

func (i *Index) Migrate(ctx context.Context) error

Migrate creates only the retrieval-owned schema and is safe to repeat.

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 in both the base and FTS tables. Empty result sets delete their document.

func (*Index) Reset

func (i *Index) Reset(ctx context.Context) error

Reset destructively removes all indexed results and FTS entries.

func (*Index) Search

func (i *Index) Search(ctx context.Context, query indexcontract.IndexQuery) ([]*retrieval.Result, error)

func (*Index) Upsert

func (i *Index) Upsert(ctx context.Context, items []*retrieval.Result) error

Jump to

Keyboard shortcuts

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