Documentation
¶
Overview ¶
Package search scans session storages for entries matching a text query.
Upstream made session search a standalone service in v0.84.2 (packages/agent/src/search/). This is the scanning implementation: it pages each session's entries oldest first and matches a projected text. Indexed backends implement the same shape by yielding Hits from their own index.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Search ¶
func Search(ctx context.Context, sessions iter.Seq2[Session, error], text string, options Options) iter.Seq2[Hit, error]
Search yields every entry whose projected text contains text, matched case-insensitively with the query trimmed. Sessions are scanned in the order the source yields them, entries oldest first. An empty query yields nothing; a session id repeated by the source, a storage failure, or a cancelled ctx ends the iteration with an error.
Types ¶
type Options ¶
type Options struct {
// EntryTypes restricts results to these canonical entry types; empty means every type.
EntryTypes []string
// Limit stops the search after this many hits; zero or less means unlimited.
Limit int
// PageSize is how many entries are read per storage query; zero defaults to 100.
PageSize int
// ProjectText builds the text matched and reported as the snippet. The
// default is the entry's JSON, with the entry's label appended when it has one.
ProjectText func(sessionID string, entry harness.SessionV4Entry, label string, labeled bool) string
}
Options bound a search.
type Readable ¶
type Readable interface {
FindEntries(query harness.SessionV4EntryQuery) ([]harness.SessionV4Entry, error)
Label(id string) (string, bool)
}
Readable is the storage subset a scan reads. Both v4 session storages satisfy it.