search

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Index

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

Index manages the FTS5 trigram index in a repo DB.

func Open

func Open(r *repo.Repo) (*Index, error)

Open creates an Index from an open repo. Creates FTS5 tables if they don't exist.

Panics if r is nil (TigerStyle precondition).

func (*Index) Drop

func (idx *Index) Drop() error

Drop removes the FTS tables entirely.

func (*Index) NeedsReindex

func (idx *Index) NeedsReindex() (bool, error)

NeedsReindex returns true if the trunk tip has advanced past the indexed checkin. Returns false if the repo has no trunk tip (empty repo).

func (*Index) RebuildIndex

func (idx *Index) RebuildIndex() error

RebuildIndex walks the trunk tip manifest, expands blob content, skips binaries and phantoms, and populates fts_content. No-ops if already current.

Panics if idx is nil (TigerStyle precondition).

func (*Index) Search

func (idx *Index) Search(q Query) ([]Result, error)

Search executes a full-text search and returns results ranked by relevance. Returns empty results (not error) if term is shorter than 3 characters.

Panics if idx is nil (TigerStyle precondition).

type Query

type Query struct {
	Term         string // search term (min 3 chars, FTS5 special chars escaped internally)
	MaxResults   int    // 0 → default (50)
	ContextLines int    // lines of surrounding context (0 → just the match line)
}

Query configures a search request.

type Result

type Result struct {
	Path     string // file pathname
	Line     int    // 1-based line number
	Column   int    // 0-based byte offset within the line
	MatchLen int    // length of matched substring
	LineText string // the matching line
	Context  string // surrounding lines including match line, newline-separated. Empty if ContextLines=0.
}

Result is a single search hit.

Jump to

Keyboard shortcuts

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