search

package
v1.10.2 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package search shares projection and query semantics across native search transports.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TargetName

func TargetName(_ string, modelVersion int) string

TargetName is the Rebuilder naming function for the search projection: targets are version tags interpreted by this sink.

Types

type Adapter

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

Adapter implements the shared search query and projection behavior.

func New

func New(t Transport, reg *registry.Registry, resolver ModelVersionResolver, transportError func(string, error) error, responseError func(string, int, string) error) *Adapter

New assembles search behavior over an authenticated native engine transport.

func (*Adapter) AggregateVersions

func (a *Adapter) AggregateVersions(ctx context.Context, tenantID string, ent *registry.Entity) (map[string]int64, error)

AggregateVersions reads id -> version for one entity's documents from the tenant's alias, the reconciler's projection side. Capped at 10k documents per entity for v1 (the match_all page limit); larger tenants reconcile via counts first and need a scroll, which is noted in OPERATIONS.md.

func (*Adapter) ApplyMutations

func (a *Adapter) ApplyMutations(ctx context.Context, target string, muts []projection.Mutation) error

ApplyMutations implements the search projection write path: one _bulk request per batch, every op carrying the aggregate version with version_type=external_gte. Stale replays come back as version conflicts and count as success, that IS the idempotency gate working.

target "" routes to the tenant's live versioned indexes (alias kept pointing at them); target "vN" routes to a rebuild's building indexes.

func (*Adapter) DropTarget

func (a *Adapter) DropTarget(ctx context.Context, target string) error

DropTarget deletes one model version's indexes for a tenant (rebuild cleanup). target is a "vN" tag.

func (*Adapter) FlipAliases

func (a *Adapter) FlipAliases(ctx context.Context, tenantID string, _, newVersion int) error

FlipAliases atomically repoints every searchable entity's tenant alias at the new model version's indexes, the search projection's blue-green cutover, one _aliases call. Removals are derived from what ACTUALLY holds each alias (entities that never indexed a document have no old index, and a remove for a nonexistent pair would fail the whole atomic action set). Wire it as the Rebuilder's OnFlip.

func (*Adapter) Ping

func (a *Adapter) Ping(ctx context.Context) error

Ping reports engine reachability, bounded by ctx.

func (*Adapter) Search

func (a *Adapter) Search(ctx context.Context, q query.SearchQuery, into any) error

Search implements query.SearchQuerier: a multi_match over the entity's DECLARED search fields against the tenant's alias, optionally narrowed by a structured Filter (non-scoring bool filter context), ordered by Sort and paginated by Offset. An absent alias (no document ever indexed for this tenant) is an empty result, not an error.

type ModelVersionResolver

type ModelVersionResolver func(context.Context, string) (int, error)

ModelVersionResolver reports the live search model version for a tenant.

type Transport

type Transport interface {
	Perform(*http.Request) (*http.Response, error)
}

Transport is the native client's HTTP request port.

Jump to

Keyboard shortcuts

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