search

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunSearchCLI

func RunSearchCLI(args []string, kisekiDB, ollamaHost, embedModel string)

RunSearchCLI handles the "kiseki search" CLI command.

func RunSearchMessagesCLI

func RunSearchMessagesCLI(args []string, kisekiDB, ollamaHost, embedModel string)

RunSearchMessagesCLI handles the "kiseki search-msg" CLI command.

Types

type MultiLayerConfig

type MultiLayerConfig struct {
	MinPerLayer      int     // floor per layer (default 50)
	VecThreshold     float64 // max vec distance to include (default 1.5)
	FTSRankThreshold float64 // unused for now, reserved for future rank filtering
	AsOf             string  // optional date filter for chunks (ISO date string)
}

MultiLayerConfig holds tuning knobs for the pipeline.

func DefaultMultiLayerConfig

func DefaultMultiLayerConfig() MultiLayerConfig

DefaultMultiLayerConfig returns sensible defaults.

type MultiLayerResult

type MultiLayerResult struct {
	Type          string   `json:"type"` // "chunk", "message", "stone"
	ID            string   `json:"id"`   // chunk ID (as string) or message ID or stone ID
	Text          string   `json:"text"`
	SourceFile    string   `json:"source_file,omitempty"`
	SectionTitle  string   `json:"section_title,omitempty"`
	ParentTitle   string   `json:"parent_title,omitempty"`
	HeaderLevel   int      `json:"header_level,omitempty"`
	ValidAt       string   `json:"valid_at,omitempty"`
	SessionID     string   `json:"session_id,omitempty"`
	Role          string   `json:"role,omitempty"`
	Timestamp     int64    `json:"timestamp,omitempty"`
	Importance    string   `json:"importance"`
	Distance      float64  `json:"distance"`      // lower = better; 0 for exact/stone
	Layers        int      `json:"layers"`        // how many search layers found this (1, 2, or 3)
	LayerSources  []string `json:"layer_sources"` // e.g. ["fts5","vec_messages"]
	IsStone       bool     `json:"is_stone,omitempty"`
	StoneID       string   `json:"stone_id,omitempty"`
	StoneTitle    string   `json:"stone_title,omitempty"`
	StoneCategory string   `json:"stone_category,omitempty"`
}

MultiLayerResult is the unified result type — can be chunk, message, or stone.

func MultiLayerSearch

func MultiLayerSearch(db *sql.DB, embedder ollama.Embedder, query string, cfg MultiLayerConfig) ([]MultiLayerResult, error)

MultiLayerSearch runs the 3-layer parallel search pipeline: entity expansion → stones → (FTS5 + vec_chunks + vec_messages in parallel) → merge + rank.

type SearchResult

type SearchResult struct {
	ID             int
	Text           string
	SourceFile     string
	SectionTitle   string
	ParentTitle    string
	HeaderLevel    int
	ValidAt        string
	Importance     string
	Distance       float64
	IsStone        bool
	StoneID        string
	StoneTitle     string
	StoneCategory  string
	StoneCreatedAt string
}
func Search(db *sql.DB, embedder ollama.Embedder, query string, limit int, asOf string) ([]SearchResult, error)

Jump to

Keyboard shortcuts

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