Documentation
¶
Overview ¶
Package search shares projection and query semantics across native search transports.
Index ¶
- func TargetName(_ string, modelVersion int) string
- type Adapter
- func (a *Adapter) AggregateVersions(ctx context.Context, tenantID string, ent *registry.Entity) (map[string]int64, error)
- func (a *Adapter) ApplyMutations(ctx context.Context, target string, muts []projection.Mutation) error
- func (a *Adapter) DropTarget(ctx context.Context, target string) error
- func (a *Adapter) FlipAliases(ctx context.Context, tenantID string, _, newVersion int) error
- func (a *Adapter) Ping(ctx context.Context) error
- func (a *Adapter) Search(ctx context.Context, q query.SearchQuery, into any) error
- type ModelVersionResolver
- type Transport
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TargetName ¶
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 ¶
DropTarget deletes one model version's indexes for a tenant (rebuild cleanup). target is a "vN" tag.
func (*Adapter) FlipAliases ¶
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) Search ¶
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 ¶
ModelVersionResolver reports the live search model version for a tenant.