search

package
v1.1.8 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package search provides MeiliSearch integration helpers for the nSelf CLI.

Index

Constants

View Source
const (
	// EnvWarmupQueries is the environment variable that holds a comma-separated
	// list of representative search query strings used to warm up the MeiliSearch
	// index cache on startup. Warm-up is skipped when the variable is empty or
	// unset.
	EnvWarmupQueries = "MEILISEARCH_WARMUP_QUERIES"
)

Variables

This section is empty.

Functions

func QueriesFromEnv

func QueriesFromEnv() []string

QueriesFromEnv reads MEILISEARCH_WARMUP_QUERIES and splits it on commas. It trims whitespace from each element and discards empties. Returns nil when the variable is unset or contains only whitespace.

Types

type WarmupConfig

type WarmupConfig struct {
	// Host is the MeiliSearch hostname (default "localhost").
	Host string
	// Port is the MeiliSearch HTTP port (default 7700).
	Port int
	// MasterKey is the MeiliSearch master key, used as the Authorization
	// header. May be empty for instances configured without auth.
	MasterKey string
	// IndexPrefix is prepended to each index name (e.g. "np_").
	IndexPrefix string
	// Queries is the list of warm-up query strings. When empty, Warmup is a
	// no-op and returns immediately without any network calls.
	Queries []string
}

WarmupConfig holds the parameters needed to run a warm-up sweep.

type WarmupResult

type WarmupResult struct {
	QueriesAttempted int
	QueriesSucceeded int
	Errors           []string
}

WarmupResult summarises a completed warm-up run.

func Warmup

func Warmup(ctx context.Context, cfg WarmupConfig) (WarmupResult, error)

Warmup issues one search request per query string against the first discoverable index on the MeiliSearch instance. It uses the multi-index search endpoint (POST /multi-search) so no specific index name is required in advance.

When cfg.Queries is empty the function returns immediately with a zero WarmupResult and a nil error. The caller should treat a warm-up as best-effort — errors are collected and returned but never fatal.

Jump to

Keyboard shortcuts

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