Help us shape the future of Go! Take the 2026 Go Developer Survey

retrieval

package
v0.10.18 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package retrieval defines the retrieval contract shared by every search backend (FTS, dense/sparse/ColBERT embedding, hybrid fusion) and by consumers that evaluate or compose them (baseline runner, ask/search commands).

It lives in the infrastructure layer because the retrieval contract is a cross-cutting dependency: business packages and test harnesses both depend on it without depending on any single backend. Keeping the contract out of internal/query (which owns specific implementations) lets measurement code (internal/baseline) import the interface without crossing a business-to-business boundary (ADR-009).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NamedRetriever

type NamedRetriever struct {
	Name      string
	Retriever Retriever
}

NamedRetriever pairs a retrieval backend with a label used for per-component score attribution in HybridRetriever. The name appears in ScoredResult.Components.

type Retriever

type Retriever interface {
	Search(ctx context.Context, query string, limit, offset int, filters index.SearchFilters) ([]ScoredResult, int, error)
}

Retriever abstracts a retrieval backend (FTS, embedding, hybrid).

type ScoredResult

type ScoredResult struct {
	ID         string             `json:"id"`
	Type       string             `json:"type"`
	Title      string             `json:"title"`
	Path       string             `json:"path"`
	Snippet    string             `json:"snippet"`
	Score      float64            `json:"score"`
	IsDomain   bool               `json:"is_domain_note"`
	Components map[string]float64 `json:"components,omitempty"`
	// AnswersGap is set when this hit is a delivered target or context item
	// that closed a gap and would carry the text line. Omitted otherwise,
	// including search, which does not credit.
	AnswersGap *index.GapCredit `json:"answers_gap,omitempty"`
}

ScoredResult is a retrieval hit with a normalized score in [0, 1]. Components, when populated, carries per-sub-retriever RRF contributions from a hybrid retrieval (e.g. {"fts": 0.0164, "dense": 0.0161}). Non-hybrid retrievers leave Components nil. The component values sum to Score.

Jump to

Keyboard shortcuts

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