Versions in this module Expand all Collapse all v0 v0.1.0 Dec 5, 2026 Changes in this version + const DefaultPerPage + const DefaultPostTag + const DefaultPreTag + const HighlightTextKey + const MaxPerPage + const ScoreField + var ErrEmptyID = errors.New("search: document id is empty") + var ErrInvalidField = errors.New("search: invalid field name") + var ErrInvalidIndexName = errors.New("search: invalid index name") + func DecodeFields[T any](h Hit) (T, error) + func FilterValues(v any) ([]any, error) + func Highlight(text string, terms []string, pre, post string) string + func Tokens(s string) []string + func ValidField(name string) error + func ValidIndexName(name string) error + type Document struct + Fields map[string]any + ID string + Metadata map[string]any + Text string + func (d Document) FieldStrings() []string + func (d Document) SearchableStrings() []string + func (d Document) Validate() error + type Engine interface + Close func() error + DeleteIndex func(ctx context.Context, name string) error + Index func(name string) Index + type FacetCount struct + Count int64 + Value string + type Hit struct + Document Document + Highlights map[string]string + ID string + Score float64 + type Index interface + Delete func(ctx context.Context, ids ...string) error + Flush func(ctx context.Context) error + Search func(ctx context.Context, q Query) (Result, error) + Upsert func(ctx context.Context, docs ...Document) error + type Manager struct + func NewManager(engine Engine) *Manager + func (m *Manager) DeleteRecord(ctx context.Context, r Searchable) error + func (m *Manager) Engine() Engine + func (m *Manager) IndexBatch(ctx context.Context, records ...Searchable) error + func (m *Manager) IndexRecord(ctx context.Context, r Searchable) error + func (m *Manager) Search(ctx context.Context, name string, q Query) (Result, error) + type Query struct + Facets []string + Filters map[string]any + HighlightFields []string + HighlightPostTag string + HighlightPreTag string + Page int + PerPage int + Sort []SortKey + Text string + func (q Query) Normalize() Query + func (q Query) Offset() int + func (q Query) Validate() error + type Result struct + Facets map[string][]FacetCount + Hits []Hit + Page int + PerPage int + Took time.Duration + Total int64 + TotalPages int + type Searchable interface + SearchIndex func() string + ToSearchDocument func() Document + type SortKey struct + Desc bool + Field string + type TypedResult struct + Items []T + func Search[T any](ctx context.Context, m *Manager, name string, q Query, ...) (TypedResult[T], error)