bulk

package
v8.10.0 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2023 License: Apache-2.0 Imports: 14 Imported by: 12

Documentation

Overview

Allows to perform multiple index/update/delete operations in a single request.

Index

Constants

This section is empty.

Variables

View Source
var ErrBuildPath = errors.New("cannot build path, check for missing path parameters")

ErrBuildPath is returned in case of missing parameters within the build of the request.

Functions

This section is empty.

Types

type Bulk

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

func New

Allows to perform multiple index/update/delete operations in a single request.

https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/docs-bulk.html

func (*Bulk) CreateOp added in v8.10.0

func (r *Bulk) CreateOp(op types.CreateOperation, doc interface{}) error

CreateOp is a helper function to add a CreateOperation to the current bulk request. doc argument can be a []byte, json.RawMessage or a struct.

func (*Bulk) DeleteOp added in v8.10.0

func (r *Bulk) DeleteOp(op types.DeleteOperation) error

DeleteOp is a helper function to add a DeleteOperation to the current bulk request.

func (Bulk) Do

func (r Bulk) Do(ctx context.Context) (*Response, error)

Do runs the request through the transport, handle the response and returns a bulk.Response

func (*Bulk) Header

func (r *Bulk) Header(key, value string) *Bulk

Header set a key, value pair in the Bulk headers map.

func (*Bulk) HttpRequest

func (r *Bulk) HttpRequest(ctx context.Context) (*http.Request, error)

HttpRequest returns the http.Request object built from the given parameters.

func (*Bulk) Index

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

Index Default index for items which don't provide one API Name: index

func (*Bulk) IndexOp added in v8.10.0

func (r *Bulk) IndexOp(op types.IndexOperation, doc interface{}) error

IndexOp is a helper function to add an IndexOperation to the current bulk request. doc argument can be a []byte, json.RawMessage or a struct.

func (Bulk) Perform

func (r Bulk) Perform(ctx context.Context) (*http.Response, error)

Perform runs the http.Request through the provided transport and returns an http.Response.

func (*Bulk) Pipeline

func (r *Bulk) Pipeline(pipeline string) *Bulk

Pipeline The pipeline id to preprocess incoming documents with API name: pipeline

func (*Bulk) Raw

func (r *Bulk) Raw(raw io.Reader) *Bulk

Raw takes a json payload as input which is then passed to the http.Request If specified Raw takes precedence on Request method.

func (*Bulk) Refresh

func (r *Bulk) Refresh(refresh refresh.Refresh) *Bulk

Refresh If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. API name: refresh

func (*Bulk) Request

func (r *Bulk) Request(req []interface{}) *Bulk

Request allows to set the request property with the appropriate payload.

func (*Bulk) RequireAlias

func (r *Bulk) RequireAlias(requirealias bool) *Bulk

RequireAlias Sets require_alias for all incoming documents. Defaults to unset (false) API name: require_alias

func (*Bulk) Routing

func (r *Bulk) Routing(routing string) *Bulk

Routing Specific routing value API name: routing

func (*Bulk) SourceExcludes_

func (r *Bulk) SourceExcludes_(fields ...string) *Bulk

SourceExcludes_ Default list of fields to exclude from the returned _source field, can be overridden on each sub-request API name: _source_excludes

func (*Bulk) SourceIncludes_

func (r *Bulk) SourceIncludes_(fields ...string) *Bulk

SourceIncludes_ Default list of fields to extract and return from the _source field, can be overridden on each sub-request API name: _source_includes

func (*Bulk) Source_

func (r *Bulk) Source_(sourceconfigparam string) *Bulk

Source_ True or false to return the _source field or not, or default list of fields to return, can be overridden on each sub-request API name: _source

func (*Bulk) Timeout

func (r *Bulk) Timeout(duration string) *Bulk

Timeout Explicit operation timeout API name: timeout

func (*Bulk) UpdateOp added in v8.10.0

func (r *Bulk) UpdateOp(op types.UpdateOperation, doc interface{}, update *types.UpdateAction) error

UpdateOp is a helper function to add an UpdateOperation with and UpdateAction to the current bulk request. update is optional, if both doc and update.Doc are provided, update.Doc has precedence.

func (*Bulk) WaitForActiveShards

func (r *Bulk) WaitForActiveShards(waitforactiveshards string) *Bulk

WaitForActiveShards Sets the number of shard copies that must be active before proceeding with the bulk operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) API name: wait_for_active_shards

type NewBulk

type NewBulk func() *Bulk

NewBulk type alias for index.

func NewBulkFunc

func NewBulkFunc(tp elastictransport.Interface) NewBulk

NewBulkFunc returns a new instance of Bulk with the provided transport. Used in the index of the library this allows to retrieve every apis in once place.

type Response

type Response struct {
	Errors     bool                                                 `json:"errors"`
	IngestTook *int64                                               `json:"ingest_took,omitempty"`
	Items      []map[operationtype.OperationType]types.ResponseItem `json:"items"`
	Took       int64                                                `json:"took"`
}

func NewResponse

func NewResponse() *Response

NewResponse returns a Response

Jump to

Keyboard shortcuts

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