search

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2026 License: MIT Imports: 8 Imported by: 0

README

Full-text search for togo. Default driver ParadeDB (Postgres BM25; portable SQL ILIKE fallback so it also runs on SQLite for dev). Elasticsearch / OpenSearch ship as driver plugins.

togo install togo-framework/search

Env: SEARCH_DRIVER (paradedb|elasticsearch|opensearch).

Documentation

Overview

Package search is togo's full-text search subsystem. The default driver is ParadeDB (Postgres BM25; it degrades to a portable SQL ILIKE search so dev on SQLite works too). Elasticsearch, OpenSearch, etc. ship as driver plugins that call search.RegisterDriver and depend on this package.

Install: `togo install togo-framework/search`.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterDriver

func RegisterDriver(name string, f DriverFactory)

RegisterDriver registers a search driver by name (call from a plugin init()).

Types

type DriverFactory

type DriverFactory func(k *togo.Kernel) (Searcher, error)

DriverFactory builds a Searcher from the kernel.

type Hit

type Hit struct {
	ID    string         `json:"id"`
	Score float64        `json:"score"`
	Doc   map[string]any `json:"doc"`
}

Hit is a single search result.

type Searcher

type Searcher interface {
	Index(ctx context.Context, index, id string, doc map[string]any) error
	Search(ctx context.Context, index, query string, limit int) ([]Hit, error)
	Delete(ctx context.Context, index, id string) error
}

Searcher indexes and queries documents grouped by index name.

type Service

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

Service is the search runtime stored on the kernel (k.Get("search")).

func FromKernel

func FromKernel(k *togo.Kernel) (*Service, bool)

FromKernel fetches the search service from the kernel container.

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, index, id string) error

func (*Service) Driver

func (s *Service) Driver() string

Driver returns the active driver name.

func (*Service) Index

func (s *Service) Index(ctx context.Context, index, id string, doc map[string]any) error

func (*Service) Search

func (s *Service) Search(ctx context.Context, index, query string, limit int) ([]Hit, error)

Jump to

Keyboard shortcuts

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