opensearch

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: MIT Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const DialectSQL = "opensearch-sql"

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Layout Layout

	// TenantField is required: a default would let a typo silently disable
	// tenant isolation.
	TenantField string

	TimestampField    string // defaults to @timestamp
	RetentionPolicyID string // ISM policy; empty disables Retention

	// TextFields names, per dataset, the field holding a record's raw text,
	// which is what OpSearch reads. A dataset missing here has no text to
	// search and OpSearch on it is an error, not an empty result.
	TextFields map[store.Dataset]string
}

type DatasetSpec

type DatasetSpec struct {
	Prefix          string
	IncludeDataType bool
	// DateFormat is a Go time layout; empty means the index does not roll.
	DateFormat string
}

DatasetSpec describes one dataset as "<prefix>[-<dataType>][-<date>]".

type Driver

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

Driver holds no connection: the os package keeps a process-wide client.

func New

func New(cfg Config) (*Driver, error)

func (*Driver) BulkWriter

func (d *Driver) BulkWriter(dataset store.Dataset) (store.BulkWriter, error)

func (*Driver) Count

func (d *Driver) Count(ctx context.Context, s store.Scope, filters []store.Filter) (int64, error)

func (*Driver) CountInWindow

func (d *Driver) CountInWindow(ctx context.Context, s store.Scope, filters []store.Filter, window time.Duration) (int64, error)

func (*Driver) DescribeFields

func (d *Driver) DescribeFields(ctx context.Context, s store.Scope) ([]store.Field, error)

func (*Driver) Dialect

func (d *Driver) Dialect() string

func (*Driver) Drop

func (d *Driver) Drop(ctx context.Context, s store.Scope) (int64, error)

Drop deletes by query rather than dropping indices, so a scoped delete can never reach another tenant's records sharing the same index.

func (*Driver) FetchByID

func (d *Driver) FetchByID(ctx context.Context, s store.Scope, id string) (json.RawMessage, error)

func (*Driver) FetchN

func (d *Driver) FetchN(ctx context.Context, s store.Scope, filters []store.Filter, n int) ([]json.RawMessage, error)

func (*Driver) FetchPage

func (d *Driver) FetchPage(ctx context.Context, s store.Scope, filters []store.Filter, page store.Page) ([]json.RawMessage, int64, error)

func (*Driver) FetchQuery

func (d *Driver) FetchQuery(ctx context.Context, s store.Scope, sql string) ([]json.RawMessage, error)

FetchQuery is RawQuery under the agnostic name

func (*Driver) Flush

func (d *Driver) Flush(ctx context.Context, dataset store.Dataset) error

func (*Driver) GroupBy

func (d *Driver) GroupBy(ctx context.Context, s store.Scope, fields []string, filters []store.Filter, opts store.GroupOpts) ([]store.Group, error)

func (*Driver) Health

func (d *Driver) Health(ctx context.Context) (store.Health, error)

func (*Driver) Insert

func (d *Driver) Insert(ctx context.Context, s store.Scope, id string, doc any) error

func (*Driver) RawQuery

func (d *Driver) RawQuery(ctx context.Context, s store.Scope, query string) ([]map[string]any, error)

RawQuery runs caller-supplied query text. It requires store.AllTenants because the driver cannot inject a tenant predicate into text it did not build — refusing is the only honest option, and it forces the caller to acknowledge that the query reads across tenants.

func (*Driver) Retention

func (d *Driver) Retention(ctx context.Context, dataset store.Dataset) (store.Retention, error)

Retention reads one ISM policy, so every dataset it covers reports the same.

func (*Driver) SetRetention

func (d *Driver) SetRetention(ctx context.Context, dataset store.Dataset, r store.Retention) error

SetRetention patches the deleting transition of the raw policy document and writes it back, so fields this package does not model survive the round trip.

func (*Driver) Timeline

func (d *Driver) Timeline(ctx context.Context, s store.Scope, filters []store.Filter, iv store.Interval) ([]store.Point, error)

func (*Driver) TimelineByField

func (d *Driver) TimelineByField(ctx context.Context, s store.Scope, field string, filters []store.Filter, iv store.Interval, n int) ([]store.Series, error)

func (*Driver) TopValues

func (d *Driver) TopValues(ctx context.Context, s store.Scope, field string, filters []store.Filter, n int) ([]store.Bucket, error)

func (*Driver) UpdateWhere

func (d *Driver) UpdateWhere(ctx context.Context, s store.Scope, filters []store.Filter, patch map[string]any) (int64, error)

func (*Driver) Usage

func (d *Driver) Usage(ctx context.Context) ([]store.DatasetUsage, error)

type Layout

type Layout interface {
	ReadIndices(s store.Scope) ([]string, error)
	WriteIndex(s store.Scope, now time.Time) (string, error)
	Datasets() []store.Dataset
	DataTypeOf(ds store.Dataset, index string) string
}

Layout maps datasets to physical indices. The application supplies one.

type SpecLayout

type SpecLayout map[store.Dataset]DatasetSpec

SpecLayout covers any prefix-and-date naming scheme without writing code.

func (SpecLayout) DataTypeOf

func (l SpecLayout) DataTypeOf(ds store.Dataset, index string) string

DataTypeOf strips the prefix and the segments the date format contributes.

func (SpecLayout) DataTypeOfPattern

func (l SpecLayout) DataTypeOfPattern(ds store.Dataset, pattern string) (dataType string, ok bool)

DataTypeOfPattern is the reverse of ReadIndices: given an index pattern as a v11 rule writes it ("v11-log-deceptive-bytes-*"), it names the dataType that pattern reads. A pattern covering every dataType ("v11-log-*") reports an empty one. ok is false for a pattern that is not of this dataset's shape — a different prefix, or a wildcard anywhere but the end — so that an unknown pattern is refused rather than read as something it is not.

func (SpecLayout) Datasets

func (l SpecLayout) Datasets() []store.Dataset

func (SpecLayout) ReadIndices

func (l SpecLayout) ReadIndices(s store.Scope) ([]string, error)

func (SpecLayout) WriteIndex

func (l SpecLayout) WriteIndex(s store.Scope, now time.Time) (string, error)

Jump to

Keyboard shortcuts

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