bulk

package
v8.13.1 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: Apache-2.0 Imports: 14 Imported by: 2

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/current/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(providedCtx 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 Name of the data stream, index, or index alias to perform bulk actions on. 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(providedCtx 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 ID of the pipeline to use to preprocess incoming documents. If the index has a default ingest pipeline specified, then setting the value to `_none` disables the default ingest pipeline for this request. If a final pipeline is configured it will always run, regardless of the value of this parameter. 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`, Elasticsearch refreshes 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` do nothing with refreshes. Valid values: `true`, `false`, `wait_for`. API name: refresh

func (*Bulk) Request

func (r *Bulk) Request(req *Request) *Bulk

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

func (*Bulk) RequireAlias

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

RequireAlias If `true`, the request’s actions must target an index alias. API name: require_alias

func (*Bulk) Routing

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

Routing Custom value used to route operations to a specific shard. API name: routing

func (*Bulk) SourceExcludes_

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

SourceExcludes_ A comma-separated list of source fields to exclude from the response. API name: _source_excludes

func (*Bulk) SourceIncludes_

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

SourceIncludes_ A comma-separated list of source fields to include in the response. 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 a list of fields to return. API name: _source

func (*Bulk) Timeout

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

Timeout Period each action waits for the following operations: automatic index creation, dynamic mapping updates, waiting for active shards. 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 The number of shard copies that must be active before proceeding with the operation. Set to all or any positive integer up to the total number of shards in the index (`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 Request added in v8.11.0

type Request = []interface{}

Request holds the request body struct for the package bulk

https://github.com/elastic/elasticsearch-specification/blob/5bf86339cd4bda77d07f6eaa6789b72f9c0279b1/specification/_global/bulk/BulkRequest.ts#L32-L103

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"`
}

Response holds the response body struct for the package bulk

https://github.com/elastic/elasticsearch-specification/blob/5bf86339cd4bda77d07f6eaa6789b72f9c0279b1/specification/_global/bulk/BulkResponse.ts#L24-L31

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