Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine performs hybrid retrieval combining vector, FTS, and graph search.
func New ¶
New creates a new retrieval engine. chatLLM is used for cross-language query translation; pass nil to disable translation.
func (*Engine) Search ¶
func (e *Engine) Search(ctx context.Context, query string, opts SearchOptions) ([]store.RetrievalResult, *SearchTrace, error)
Search performs hybrid retrieval using RRF to fuse results from vector search, FTS5, and graph-based retrieval. Returns fused results and a SearchTrace with the full breakdown.
type FusedResultInfo ¶
type FusedResultInfo struct {
Methods []string `json:"methods"`
VecRank int `json:"vec_rank,omitempty"` // 1-based, 0 = not present
FTSRank int `json:"fts_rank,omitempty"` // 1-based, 0 = not present
GraphRank int `json:"graph_rank,omitempty"` // 1-based, 0 = not present
}
FusedResultInfo holds per-result method contribution metadata.
type SearchOptions ¶
type SearchOptions struct {
MaxResults int
WeightVec float64
WeightFTS float64
WeightGraph float64
}
SearchOptions configures a single search operation.
type SearchTrace ¶
type SearchTrace struct {
VecResults int `json:"vec_results"`
FTSResults int `json:"fts_results"`
GraphResults int `json:"graph_results"`
FusedResults int `json:"fused_results"`
VecWeight float64 `json:"vec_weight"`
FTSWeight float64 `json:"fts_weight"`
GraphWeight float64 `json:"graph_weight"`
IdentifiersDetected bool `json:"identifiers_detected"`
SynthesisMode bool `json:"synthesis_mode"`
MaxRequested int `json:"max_requested"`
FollowUpTerms []string `json:"follow_up_terms,omitempty"`
FollowUpResults int `json:"follow_up_results,omitempty"`
FTSQuery string `json:"fts_query"`
GraphEntities []string `json:"graph_entities"`
ElapsedMs int64 `json:"elapsed_ms"`
PerResult map[int64]FusedResultInfo `json:"per_result,omitempty"`
}
SearchTrace records the full breakdown of a hybrid search operation.
type Translator ¶
type Translator struct {
// contains filtered or unexported fields
}
Translator provides cross-language query expansion by reading corpus languages from the database and translating query terms to all non-English document languages via an LLM at runtime. Results are cached in memory so each unique term is only translated once per engine lifetime.
func NewTranslator ¶
func NewTranslator(chatLLM llm.Provider, s *store.Store) *Translator
NewTranslator creates a Translator. If chatLLM is nil translation is a no-op (all methods return nil).
func (*Translator) Languages ¶
func (t *Translator) Languages() []string
Languages returns the corpus languages, reading from the DB on first call and caching thereafter. Returns nil if no languages are detected.
func (*Translator) TranslateTerms ¶
func (t *Translator) TranslateTerms(ctx context.Context, terms []string) []string
TranslateTerms translates English query terms to all non-English corpus languages. Returns additional terms (translated forms) to append to search queries. Returns nil if all docs are English, no languages are detected, or chatLLM is nil.