bulk

package
v0.192.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInitIndexer = errors.New("indexer not initialised")
)

Functions

func AddAction added in v0.190.3

func AddAction[T ~string](
	ctx context.Context,
	actions ...*Action[T],
) error

AddAction sends the given actions to the indexer.

func Flush added in v0.190.3

func Flush(ctx context.Context) error

Flush will flush all pending bulk actions, forcing Elasticsearch to process them.

func IndexDocuments added in v0.190.3

func IndexDocuments[T ~string, O Document[T]](
	ctx context.Context,
	index string,
	documents ...O,
) error

IndexDocuments wraps AddAction to bulk index the given documents to the given index.

func Shutdown added in v0.190.3

func Shutdown(ctx context.Context) error

Shutdown gracefully closes the indexer (if it has been initialized/created).

Types

type Action added in v0.190.3

type Action[T ~string] struct {
	// contains filtered or unexported fields
}

Action represents a single bulk action.

func NewAction added in v0.190.3

func NewAction[T ~string](doc Document[T], options ...ActionOption[T]) *Action[T]

NewAction creates a new bulk action for the given document, with the given options.

type ActionOption added in v0.190.3

type ActionOption[T ~string] func(*Action[T])

ActionOption is a functional option applied to an action.

func AsOperation added in v0.190.3

func AsOperation[T ~string](op Operation) ActionOption[T]

func ToIndex

func ToIndex[T ~string](index string) ActionOption[T]

ToIndex option defines the index to operate on.

func WithRetries added in v0.190.3

func WithRetries[T ~string](retries int) ActionOption[T]

WithRetries option defines the number of retries if this action fails. Set to zero to disable retries.

type Document added in v0.190.3

type Document[T ~string] interface {
	GetID() T
}

Document represents any type of document stored in any index.

type Indexer added in v0.190.3

type Indexer struct {
	esutil.BulkIndexer
}

Indexer represents a bulk indexer instance. The indexer instance is generally created once when needed and then reused throughout the application life cycle.

func NewIndexer added in v0.190.3

func NewIndexer(ctx context.Context, options ...IndexerOption) (*Indexer, error)

NewIndexer creates a new indexer. It will initialize the indexer once, if not done already, then return the instance.

type IndexerOption added in v0.190.3

type IndexerOption func(*esutil.BulkIndexerConfig)

IndexerOption is a functional option to apply to an indexer instance.

func WithFlushInterval added in v0.190.3

func WithFlushInterval(interval, jitter time.Duration) IndexerOption

WithFlushInterval defines the interval (with jitter) after which any pending bulk operations will be flushed.

type Operation

type Operation string

Operation is the type of bulk operation for a given action.

const (
	OpIndex  Operation = "index"
	OpCreate Operation = "create"
	OpUpdate Operation = "update"
	OpDelete Operation = "delete"
)

type PartialDocument added in v0.190.3

type PartialDocument struct {
	Parts map[string]any `json:"doc"`
	ID    string         `json:"-"`
}

PartialDocument represents partial data for a given document.

func (*PartialDocument) GetID added in v0.190.3

func (d *PartialDocument) GetID() string

Jump to

Keyboard shortcuts

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