search

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IndexFileName = "search-index.json"
)

Variables

This section is empty.

Functions

func ExtractText

func ExtractText(value any) string

func FormatResult

func FormatResult(result Result) string

func NormalizeQuery

func NormalizeQuery(query string) string

Types

type EventSummary

type EventSummary struct {
	ID        string             `json:"id"`
	Sequence  int                `json:"sequence"`
	Type      sessions.EventType `json:"type"`
	CreatedAt string             `json:"createdAt"`
}

type Hit

type Hit struct {
	Session sessions.Metadata `json:"session"`
	Event   EventSummary      `json:"event"`
	Context string            `json:"context"`
	Match   Match             `json:"match"`
}

type Index

type Index struct {
	SchemaVersion     int          `json:"schemaVersion"`
	SessionID         string       `json:"sessionId"`
	SessionUpdatedAt  string       `json:"sessionUpdatedAt"`
	SessionEventCount int          `json:"sessionEventCount"`
	GeneratedAt       string       `json:"generatedAt"`
	Entries           []IndexEntry `json:"entries"`
}

func LoadIndex

func LoadIndex(store *sessions.Store, session sessions.Metadata, options LoadOptions) (Index, error)

func RebuildIndex

func RebuildIndex(store *sessions.Store, session sessions.Metadata, now func() time.Time) (Index, error)

type IndexEntry

type IndexEntry struct {
	SessionID string             `json:"sessionId"`
	EventID   string             `json:"eventId"`
	Sequence  int                `json:"sequence"`
	Type      sessions.EventType `json:"type"`
	CreatedAt string             `json:"createdAt"`
	Text      string             `json:"text"`
}

type LoadOptions

type LoadOptions struct {
	Reindex bool
	Now     func() time.Time
}

type Match

type Match struct {
	Start int `json:"start"`
	End   int `json:"end"`
}

type Options

type Options struct {
	Store        *sessions.Store
	RootDir      string
	Limit        int
	ContextChars int
	SessionID    string
	Type         sessions.EventType
	Reindex      bool
	Now          func() time.Time
}

type Result

type Result struct {
	Query            string `json:"query"`
	NormalizedQuery  string `json:"normalizedQuery"`
	RootDir          string `json:"rootDir"`
	SearchedSessions int    `json:"searchedSessions"`
	// SkippedSessions counts sessions whose event log could not be read or
	// indexed; they are skipped so one corrupt session can't abort the search.
	SkippedSessions int   `json:"skippedSessions,omitempty"`
	TotalHits       int   `json:"totalHits"`
	Hits            []Hit `json:"hits"`
}

func RedactResult

func RedactResult(result Result) Result

func Sessions

func Sessions(query string, options Options) (Result, error)

Jump to

Keyboard shortcuts

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