search

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package search ranks bounded records from the canonical SQLite index.

Index

Constants

View Source
const (
	MatchText   = "text"
	MatchFixed  = "fixed"
	MatchRegexp = "regexp"
)
View Source
const (
	MaxResults    = 100
	MaxQueryBytes = 16 * 1024
	MaxQueryTerms = 256
)

Variables

View Source
var ErrSemanticUnavailable = errors.New("semantic search is unavailable")

Functions

This section is empty.

Types

type FilesystemOptions added in v0.4.0

type FilesystemOptions struct {
	Limit         int
	Scope         string
	IgnoreGlobs   []string
	MaxFileBytes  int64
	RequestedMode string
	MatchKind     string
	About         string
}

FilesystemOptions bounds the live lexical fallback used while the durable index is being replaced. It deliberately has no semantic or graph inputs.

type LexicalQuery added in v0.4.0

type LexicalQuery struct {
	Kind    string `json:"kind"`
	Pattern string `json:"pattern"`
}

type Options

type Options struct {
	Mode          string
	Limit         int
	Root          string
	Scope         string
	MatchKind     string
	About         string
	HasExtractors bool
	Embedding     *config.Embedding
}

type QueryPlan added in v0.4.0

type QueryPlan struct {
	Lexical  LexicalQuery   `json:"lexical"`
	Semantic *SemanticQuery `json:"semantic,omitempty"`
	Scope    string         `json:"scope,omitempty"`
	// contains filtered or unexported fields
}

func PlanQuery added in v0.4.0

func PlanQuery(pattern, matchKind, about, scope string) (QueryPlan, error)

type RankedRecord

type RankedRecord struct {
	Path      string         `json:"path"`
	StartLine int            `json:"startLine"`
	EndLine   int            `json:"endLine"`
	Kind      string         `json:"kind,omitempty"`
	Title     string         `json:"title,omitempty"`
	Excerpt   string         `json:"excerpt"`
	Metadata  map[string]any `json:"metadata,omitempty"`
	Source    string         `json:"source,omitempty"`
	Retrieval []string       `json:"-"`
	Score     float64        `json:"-"`
	// contains filtered or unexported fields
}

func (RankedRecord) MarshalJSON added in v0.3.0

func (r RankedRecord) MarshalJSON() ([]byte, error)

type Result

type Result struct {
	Schema         string         `json:"schema"`
	Query          string         `json:"query"`
	RequestedMode  string         `json:"requestedMode"`
	ActiveMode     string         `json:"activeMode"`
	FallbackReason string         `json:"fallbackReason,omitempty"`
	ElapsedMS      int64          `json:"elapsedMs"`
	QueryPlan      QueryPlan      `json:"queryPlan"`
	Records        []RankedRecord `json:"records"`
	MorePaths      []string       `json:"morePaths,omitempty"`
}

func Run

func Run(ctx context.Context, value *store.Store, query string, opts Options) (Result, error)

func RunFilesystem added in v0.4.0

func RunFilesystem(
	ctx context.Context,
	root, query string,
	opts FilesystemOptions,
) (Result, error)

RunFilesystem searches current working-tree files without consulting the SQLite index. This keeps default search available during an index run without returning records that were deleted or changed after the last commit.

type SemanticQuery added in v0.4.0

type SemanticQuery struct {
	Text   string `json:"text"`
	Source string `json:"source"`
}

Jump to

Keyboard shortcuts

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