bulk

package
v1.2.5-prerelease3 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const UnknownStatusCode = -1

Variables

This section is empty.

Functions

This section is empty.

Types

type BulkDeleteRequest

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

BulkDeleteRequest is a request to remove a document from Elasticsearch.

See https://www.elastic.co/guide/en/elasticsearch/reference/7.0/docs-bulk.html for details.

func NewBulkDeleteRequest

func NewBulkDeleteRequest() *BulkDeleteRequest

NewBulkDeleteRequest returns a new BulkDeleteRequest.

func (*BulkDeleteRequest) ID

ID specifies the identifier of the document to delete.

func (*BulkDeleteRequest) Index

func (r *BulkDeleteRequest) Index(index string) *BulkDeleteRequest

Index specifies the Elasticsearch index to use for this delete request. If unspecified, the index set on the BulkService will be used.

func (*BulkDeleteRequest) Source

func (r *BulkDeleteRequest) Source() ([]string, error)

Source returns the on-wire representation of the delete request, split into an action-and-meta-data line and an (optional) source line. See https://www.elastic.co/guide/en/elasticsearch/reference/7.0/docs-bulk.html for details.

func (*BulkDeleteRequest) String

func (r *BulkDeleteRequest) String() string

String returns the on-wire representation of the delete request, concatenated as a single string.

func (*BulkDeleteRequest) Type

Type specifies the Elasticsearch type to use for this delete request. If unspecified, the type set on the BulkService will be used.

func (*BulkDeleteRequest) Version

func (r *BulkDeleteRequest) Version(version int64) *BulkDeleteRequest

Version indicates the version to be deleted as part of an optimistic concurrency model.

func (*BulkDeleteRequest) VersionType

func (r *BulkDeleteRequest) VersionType(versionType string) *BulkDeleteRequest

VersionType can be "internal" (default), "external", "external_gte", or "external_gt".

type BulkIndexRequest

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

func NewBulkIndexRequest

func NewBulkIndexRequest() *BulkIndexRequest

NewBulkIndexRequest returns a new BulkIndexRequest. The operation type is "index" by default.

func (*BulkIndexRequest) Doc

func (r *BulkIndexRequest) Doc(doc interface{}) *BulkIndexRequest

Doc specifies the document to index.

func (*BulkIndexRequest) ID

ID specifies the identifier of the document to index.

func (*BulkIndexRequest) Index

func (r *BulkIndexRequest) Index(index string) *BulkIndexRequest

Index specifies the Elasticsearch index to use for this index request. If unspecified, the index set on the BulkService will be used.

func (*BulkIndexRequest) OpType

func (r *BulkIndexRequest) OpType(opType string) *BulkIndexRequest

OpType specifies if this request should follow create-only or upsert behavior. This follows the OpType of the standard document index API. See https://www.elastic.co/guide/en/elasticsearch/reference/7.0/docs-index_.html#operation-type for details.

func (*BulkIndexRequest) Source

func (r *BulkIndexRequest) Source() ([]string, error)

Source returns the on-wire representation of the index request, split into an action-and-meta-data line and an (optional) source line. See https://www.elastic.co/guide/en/elasticsearch/reference/7.0/docs-bulk.html for details.

func (*BulkIndexRequest) String

func (r *BulkIndexRequest) String() string

String returns the on-wire representation of the index request, concatenated as a single string.

func (*BulkIndexRequest) Type

Type specifies the Elasticsearch type to use for this index request. If unspecified, the type set on the BulkService will be used.

func (*BulkIndexRequest) Version

func (r *BulkIndexRequest) Version(version int64) *BulkIndexRequest

Version indicates the version of the document as part of an optimistic concurrency model.

func (*BulkIndexRequest) VersionType

func (r *BulkIndexRequest) VersionType(versionType string) *BulkIndexRequest

VersionType specifies how versions are created. It can be e.g. internal, external, external_gte, or force.

See https://www.elastic.co/guide/en/elasticsearch/reference/7.0/docs-index_.html#index-versioning for details.

type BulkProcessorParameters

type BulkProcessorParameters struct {
	Name          string
	NumOfWorkers  int
	BulkActions   int
	BulkSize      int
	FlushInterval time.Duration
	Backoff       GenericBackoff
	BeforeFunc    GenericBulkBeforeFunc
	AfterFunc     GenericBulkAfterFunc
}

BulkProcessorParameters holds all required and optional parameters for executing bulk service

type BulkUpdateRequest

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

BulkUpdateRequest is a request to update a document in Elasticsearch.

See https://www.elastic.co/guide/en/elasticsearch/reference/7.0/docs-bulk.html for details.

func NewBulkUpdateRequest

func NewBulkUpdateRequest() *BulkUpdateRequest

NewBulkUpdateRequest returns a new BulkUpdateRequest.

func (*BulkUpdateRequest) Doc

func (r *BulkUpdateRequest) Doc(doc interface{}) *BulkUpdateRequest

Doc specifies the updated document.

func (*BulkUpdateRequest) ID

ID specifies the identifier of the document to update.

func (*BulkUpdateRequest) Index

func (r *BulkUpdateRequest) Index(index string) *BulkUpdateRequest

Index specifies the Elasticsearch index to use for this update request. If unspecified, the index set on the BulkService will be used.

func (*BulkUpdateRequest) Source

func (r *BulkUpdateRequest) Source() ([]string, error)

Source returns the on-wire representation of the update request, split into an action-and-meta-data line and an (optional) source line. See https://www.elastic.co/guide/en/elasticsearch/reference/7.0/docs-bulk.html for details.

func (*BulkUpdateRequest) String

func (r *BulkUpdateRequest) String() string

String returns the on-wire representation of the update request, concatenated as a single string.

func (*BulkUpdateRequest) Version

func (r *BulkUpdateRequest) Version(version int64) *BulkUpdateRequest

Version indicates the version of the document as part of an optimistic concurrency model.

func (*BulkUpdateRequest) VersionType

func (r *BulkUpdateRequest) VersionType(versionType string) *BulkUpdateRequest

VersionType can be "internal" (default), "external", "external_gte", or "external_gt".

type GenericBackoff

type GenericBackoff interface {
	// Next implements a BackoffFunc.
	Next(retry int) (time.Duration, bool)
}

GenericBackoff allows callers to implement their own Backoff strategy.

func NewExponentialBackoff

func NewExponentialBackoff(initialTimeout, maxTimeout time.Duration) GenericBackoff

NewExponentialBackoff returns a exponentialBackoff backoff policy. Use initialTimeout to set the first/minimal interval and maxTimeout to set the maximum wait interval.

type GenericBulkAfterFunc

type GenericBulkAfterFunc func(executionId int64, requests []GenericBulkableRequest, response *GenericBulkResponse, err *GenericError)

GenericBulkAfterFunc defines the signature of callbacks that are executed after a commit to Elasticsearch. The err parameter signals an error.

type GenericBulkBeforeFunc

type GenericBulkBeforeFunc func(executionId int64, requests []GenericBulkableRequest)

GenericBulkBeforeFunc defines the signature of callbacks that are executed before a commit to Elasticsearch.

type GenericBulkProcessor

type GenericBulkProcessor interface {
	Start(ctx context.Context) error
	Stop() error
	Close() error
	Add(request *GenericBulkableAddRequest)
	Flush() error
}

GenericBulkProcessor is a bulk processor

type GenericBulkResponse

type GenericBulkResponse struct {
	Took   int                                   `json:"took,omitempty"`
	Errors bool                                  `json:"errors,omitempty"`
	Items  []map[string]*GenericBulkResponseItem `json:"items,omitempty"`
}

GenericBulkResponse is generic struct of bulk response

type GenericBulkResponseItem

type GenericBulkResponseItem struct {
	Index   string `json:"_index,omitempty"`
	Type    string `json:"_type,omitempty"`
	ID      string `json:"_id,omitempty"`
	Version int64  `json:"_version,omitempty"`
	Result  string `json:"result,omitempty"`
	Status  int    `json:"status,omitempty"`
	// the error details
	Error interface{}
}

GenericBulkResponseItem is the result of a single bulk request.

type GenericBulkableAddRequest

type GenericBulkableAddRequest struct {
	Index       string
	Type        string
	ID          string
	VersionType string
	Version     int64
	// request types can be index, delete or create
	RequestType GenericBulkableRequestType
	// should be nil if IsDelete is true
	Doc interface{}
}

GenericBulkableAddRequest a struct to hold a bulk request

type GenericBulkableRequest

type GenericBulkableRequest interface {
	String() string
	Source() ([]string, error)
}

GenericBulkableRequest is a generic interface to bulkable requests.

type GenericBulkableRequestType

type GenericBulkableRequestType int
const (
	BulkableIndexRequest GenericBulkableRequestType = iota
	BulkableDeleteRequest
	BulkableCreateRequest
)

type GenericError

type GenericError struct {
	Status  int   `json:"status"`
	Details error `json:"error,omitempty"`
}

GenericError encapsulates error status and details returned from Elasticsearch.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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