index

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package index owns the rebuildable SQLite cache and all SQL access.

Index

Constants

This section is empty.

Variables

View Source
var ErrIndex = errors.New("index error")

Functions

func CachePath

func CachePath(root string) (string, error)

CachePath hashes the physical root so filesystem aliases share one cache.

func Error

func Error(err error) error

func IsUnreadable

func IsUnreadable(err error) bool

IsUnreadable distinguishes open/schema failures from ordinary query errors.

Types

type Backlink struct {
	From  string `json:"from" jsonschema:"from"`
	Line  int    `json:"line" jsonschema:"line"`
	Alias string `json:"alias" jsonschema:"alias"`
	Embed bool   `json:"embed" jsonschema:"embed"`
}

type Broken

type Broken struct {
	Broken    []BrokenLink `json:"broken" jsonschema:"broken"`
	Total     int          `json:"total" jsonschema:"total"`
	Truncated bool         `json:"truncated" jsonschema:"truncated"`
}
type BrokenLink struct {
	From   string `json:"from" jsonschema:"from"`
	Target string `json:"target" jsonschema:"target"`
	Line   int    `json:"line" jsonschema:"line"`
	Reason string `json:"reason" jsonschema:"reason"`
}

type EmbedNote

type EmbedNote struct {
	ID, Title, Body string
	MTime, Size     int64
	Current         bool
}

type EmbeddingCounts

type EmbeddingCounts struct {
	Model  string `json:"model"`
	Notes  int    `json:"notes"`
	Chunks int    `json:"chunks"`
}

type Incoming

type Incoming struct {
	ID        string     `json:"id" jsonschema:"id"`
	Backlinks []Backlink `json:"backlinks" jsonschema:"backlinks"`
}

type Index

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

func Open

func Open(root string) (*Index, error)

func OpenForReindex

func OpenForReindex(root string) (*Index, error)

OpenForReindex discards an unreadable cache and all SQLite sidecars before retrying.

func (i *Index) Backlinks(ctx context.Context, id string) (Incoming, error)

func (*Index) Broken

func (i *Index) Broken(ctx context.Context) (Broken, error)

func (*Index) Close

func (i *Index) Close() error

func (*Index) Count

func (i *Index) Count(ctx context.Context) (int, error)

func (*Index) EmbedNotes

func (i *Index) EmbedNotes(ctx context.Context, model string) ([]EmbedNote, error)

func (*Index) EmbeddingCounts

func (i *Index) EmbeddingCounts(ctx context.Context, model string) (EmbeddingCounts, error)

func (*Index) Keyword

func (i *Index) Keyword(ctx context.Context, query string, limit int) ([]Match, error)

func (*Index) LinkCounts

func (i *Index) LinkCounts(ctx context.Context) (links, broken, orphans int, err error)

LinkCounts returns the graph totals, independently of report caps.

func (i *Index) Links(ctx context.Context, id string) (Outgoing, error)

func (*Index) List

func (i *Index) List(ctx context.Context, tag string, limit int) (Listing, error)

func (*Index) Orphans

func (i *Index) Orphans(ctx context.Context) (Orphans, error)

func (*Index) StoreEmbeddings

func (i *Index) StoreEmbeddings(ctx context.Context, n EmbedNote, model string, vectors [][]float32) error

StoreEmbeddings publishes a complete note only if its indexed stamp still matches.

func (*Index) Sync

func (i *Index) Sync(ctx context.Context, root string, full bool) error

Sync atomically applies changed files and removes vanished notes.

func (*Index) SyncNote

func (i *Index) SyncNote(ctx context.Context, root, id string) error

SyncNote reindexes one written note and reconsiders graph resolution.

func (*Index) Tags

func (i *Index) Tags(ctx context.Context) ([]Tag, error)

func (*Index) Vectors

func (i *Index) Vectors(ctx context.Context, model string) ([]Vector, error)
type Link struct {
	Target   string  `json:"target" jsonschema:"target"`
	TargetID *string `json:"target_id" jsonschema:"target id"`
	Heading  string  `json:"heading" jsonschema:"heading"`
	Alias    string  `json:"alias" jsonschema:"alias"`
	Embed    bool    `json:"embed" jsonschema:"embed"`
	Line     int     `json:"line" jsonschema:"line"`
	Resolved bool    `json:"resolved" jsonschema:"resolved"`
}

type Listing

type Listing struct {
	Notes     []Summary `json:"notes" jsonschema:"notes"`
	Total     int       `json:"total" jsonschema:"total"`
	Truncated bool      `json:"truncated" jsonschema:"truncated"`
}

type Match

type Match struct {
	ID, Title string
	Score     float64
	Snippet   string
}

Match is the storage result; search owns the public Hit contract.

type Orphan

type Orphan struct {
	ID    string `json:"id" jsonschema:"id"`
	Title string `json:"title" jsonschema:"title"`
}

type Orphans

type Orphans struct {
	Orphans   []Orphan `json:"orphans" jsonschema:"orphans"`
	Total     int      `json:"total" jsonschema:"total"`
	Truncated bool     `json:"truncated" jsonschema:"truncated"`
}

type Outgoing

type Outgoing struct {
	ID    string `json:"id" jsonschema:"id"`
	Links []Link `json:"links" jsonschema:"links"`
}

type Summary

type Summary struct {
	Problem string   `json:"problem,omitempty" jsonschema:"problem"`
	ID      string   `json:"id" jsonschema:"id"`
	Title   string   `json:"title" jsonschema:"title"`
	Tags    []string `json:"tags" jsonschema:"tags"`
}

type Tag

type Tag struct {
	Name  string `json:"name" jsonschema:"name"`
	Count int    `json:"count" jsonschema:"count"`
}

type Vector

type Vector struct {
	ID, Title, Body string
	Chunk           int
	Values          []float32
}

Jump to

Keyboard shortcuts

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