search

package
v0.0.0-...-360ba47 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2026 License: GPL-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckOllamaSetup

func CheckOllamaSetup(ollamaURL string) error

CheckOllamaSetup verifies Ollama is available

func CleanupIndex

func CleanupIndex(db *sql.DB, repoRoot string) error

CleanupIndex removes entries for non-existent files

func FormatSearchResults

func FormatSearchResults(results []SearchResult, query string, maxResults int) string

FormatSearchResults formats search results for display

func GetRelevanceLabel

func GetRelevanceLabel(score float32) string

GetRelevanceLabel returns a human-readable relevance label based on score

func InitSearchDB

func InitSearchDB(dbPath string) (*sql.DB, error)

InitSearchDB initializes the SQLite database for storing embeddings

func PrintSearchHelp

func PrintSearchHelp()

PrintSearchHelp prints help information for search commands

func UpdateIndex

func UpdateIndex(db *sql.DB, cfg *SearchConfig, repoRoot string, excludedPaths []string) error

UpdateIndex performs incremental update of the index

func ValidateIndex

func ValidateIndex(db *sql.DB, repoRoot string) error

ValidateIndex checks the integrity of the search index

Types

type FileInfo

type FileInfo struct {
	FilePath     string
	ContentHash  string
	Embedding    []float32
	LastModified int64
	FileSize     int64
	IndexedAt    int64
}

FileInfo holds metadata about indexed files

type IndexStats

type IndexStats struct {
	TotalFiles   int
	IndexedFiles int
	SkippedFiles int
	ErrorFiles   int
	StartTime    time.Time
	EndTime      time.Time
	BytesIndexed int64
}

IndexStats holds statistics about indexing operation

func IndexRepository

func IndexRepository(db *sql.DB, cfg *SearchConfig, repoRoot string, excludedPaths []string, showProgress bool, reindexAll bool) (*IndexStats, error)

IndexRepository walks through repository and indexes files

type OllamaEmbeddingRequest

type OllamaEmbeddingRequest struct {
	Model  string `json:"model"`
	Prompt string `json:"prompt"`
}

OllamaEmbeddingRequest represents the request to Ollama API

type OllamaEmbeddingResponse

type OllamaEmbeddingResponse struct {
	Embedding []float64 `json:"embedding"`
}

OllamaEmbeddingResponse represents the response from Ollama API

type SearchCommands

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

SearchCommands handles search-related CLI commands

func NewSearchCommands

func NewSearchCommands(cfg *SearchConfig, repoRoot string) (*SearchCommands, error)

NewSearchCommands creates a new search commands handler

func (*SearchCommands) Close

func (sc *SearchCommands) Close() error

Close closes the search commands handler

func (*SearchCommands) HandleReindex

func (sc *SearchCommands) HandleReindex(excludedPaths []string, showProgress bool) error

HandleReindex handles the reindex command

func (*SearchCommands) HandleSearchCleanup

func (sc *SearchCommands) HandleSearchCleanup() error

HandleSearchCleanup handles the search cleanup command

func (*SearchCommands) HandleSearchStatus

func (sc *SearchCommands) HandleSearchStatus() error

HandleSearchStatus handles the search status command

func (*SearchCommands) HandleSearchUpdate

func (sc *SearchCommands) HandleSearchUpdate(excludedPaths []string) error

HandleSearchUpdate handles the search update command

func (*SearchCommands) HandleSearchValidate

func (sc *SearchCommands) HandleSearchValidate() error

HandleSearchValidate handles the search validate command

func (*SearchCommands) InitializeSearchIndex

func (sc *SearchCommands) InitializeSearchIndex(excludedPaths []string, showProgress bool) error

InitializeSearchIndex creates initial index if needed

func (*SearchCommands) Search

func (sc *SearchCommands) Search(query string) (string, error)

Search performs a search and returns formatted results

type SearchConfig

type SearchConfig struct {
	Enabled            bool     `yaml:"enabled"`
	VectorDBPath       string   `yaml:"vector_db_path"`
	EmbeddingModel     string   `yaml:"embedding_model"`
	MaxResults         int      `yaml:"max_results"`
	MinSimilarityScore float64  `yaml:"min_similarity_score"`
	MaxPreviewLength   int      `yaml:"max_preview_length"`
	OllamaURL          string   `yaml:"ollama_url"`
	IndexExtensions    []string `yaml:"index_extensions"`
	MaxFileSize        int64    `yaml:"max_file_size"`
}

SearchConfig holds search-related configuration

type SearchEngine

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

SearchEngine provides semantic search functionality

func NewSearchEngine

func NewSearchEngine(cfg *SearchConfig, repoRoot string) (*SearchEngine, error)

NewSearchEngine creates a new search engine instance

func (*SearchEngine) Close

func (se *SearchEngine) Close() error

Close closes the search engine and its resources

func (*SearchEngine) GetConfig

func (se *SearchEngine) GetConfig() *SearchConfig

GetConfig returns the search configuration

func (*SearchEngine) GetDB

func (se *SearchEngine) GetDB() *sql.DB

GetDB returns the underlying database connection

func (*SearchEngine) GetRepoRoot

func (se *SearchEngine) GetRepoRoot() string

GetRepoRoot returns the repository root path

func (*SearchEngine) Search

func (se *SearchEngine) Search(query string) ([]SearchResult, error)

Search performs a semantic search for the given query

type SearchResult

type SearchResult struct {
	FilePath  string
	Score     float32
	Preview   string
	LineCount int
	FileSize  int64
	Relevance string
}

SearchResult represents a single search result

Jump to

Keyboard shortcuts

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