search

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetStopWords

func GetStopWords() []string

GetStopWords returns a copy of the current stop word set.

func SetStopWords

func SetStopWords(words []string)

SetStopWords replaces the default stop word list with a custom set. Pass nil or an empty slice to disable stop word filtering entirely.

Types

type HybridSearch

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

HybridSearch combines lexical, semantic, and structural search with composite scoring

func New

func New(store *storage.Store, embedder embedding.Embedder, graph *graph.GraphEngine) *HybridSearch

New creates a new HybridSearch engine with default configuration.

func NewWithConfig

func NewWithConfig(store *storage.Store, embedder embedding.Embedder, graph *graph.GraphEngine, config SearchConfig) *HybridSearch

NewWithConfig creates a new HybridSearch engine with a custom configuration.

func (*HybridSearch) Search

func (h *HybridSearch) Search(query string, limit int, activeFileNodeIDs []string, maxPerFile ...int) ([]types.SearchResult, error)

Search performs multi-signal composite search. maxPerFile controls how many results per unique file_path are returned (0 uses default of 3).

type SearchConfig

type SearchConfig struct {
	// Composite scoring weights (should sum to ~1.0)
	WeightPPR         float64
	WeightBM25        float64
	WeightBetweenness float64
	WeightInDegree    float64
	WeightSemantic    float64

	// Node-type boost multipliers (applied when query intent matches node type)
	RouteBoost       float64 // route query + NodeTypeRoute
	RouteMethodBoost float64 // route query + NodeTypeMethod
	ClassBoost       float64 // class query + NodeTypeClass/Interface
	FunctionBoost    float64 // function query + NodeTypeFunction

	// Path penalty multipliers (lower = more penalty)
	PenaltyGenerated float64 // _ide_helper, .d.ts, generated/
	PenaltyVendor    float64 // vendor/, node_modules/, lib/
	PenaltyMigration float64 // migrations/, migration/
	PenaltyTest      float64 // tests/, test/, *_test.go, etc.
	PenaltyExample   float64 // examples/
	PenaltyConfig    float64 // config/

	// Graph expansion parameters
	ExpansionSeedCount       int     // top-N results to expand from
	ExpansionMaxNeighbors    int     // max neighbors to consider per expansion
	ExpansionMaxAddedDivisor int     // maxAdded = limit / this value
	ExpansionBonus           float64 // fraction of seed score for connectivity bonus

	// Per-file cap parameters
	NonCoreThreshold float64 // pathPenalty at or below this → non-core (capped)

	// Search pipeline parameters
	BM25ScoreFloor      float64 // min normalized BM25 for nodes with positive raw score
	CandidateMultiplier int     // candidateLimit = limit * this
	CandidateMinimum    int     // minimum candidateLimit
	MaxPerFile          int     // default max results per file_path
}

SearchConfig holds all tunable parameters for the hybrid search pipeline.

func DefaultConfig

func DefaultConfig() SearchConfig

DefaultConfig returns the current production configuration.

Jump to

Keyboard shortcuts

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