Documentation ¶
Overview ¶
Allows to perform multiple index/update/delete operations in a single request.
Index ¶
- Variables
- type Bulk
- func (r *Bulk) CreateOp(op types.CreateOperation, doc interface{}) error
- func (r *Bulk) DeleteOp(op types.DeleteOperation) error
- func (r Bulk) Do(providedCtx context.Context) (*Response, error)
- func (r *Bulk) Header(key, value string) *Bulk
- func (r *Bulk) HttpRequest(ctx context.Context) (*http.Request, error)
- func (r *Bulk) Index(index string) *Bulk
- func (r *Bulk) IndexOp(op types.IndexOperation, doc interface{}) error
- func (r Bulk) Perform(providedCtx context.Context) (*http.Response, error)
- func (r *Bulk) Pipeline(pipeline string) *Bulk
- func (r *Bulk) Raw(raw io.Reader) *Bulk
- func (r *Bulk) Refresh(refresh refresh.Refresh) *Bulk
- func (r *Bulk) Request(req *Request) *Bulk
- func (r *Bulk) RequireAlias(requirealias bool) *Bulk
- func (r *Bulk) Routing(routing string) *Bulk
- func (r *Bulk) SourceExcludes_(fields ...string) *Bulk
- func (r *Bulk) SourceIncludes_(fields ...string) *Bulk
- func (r *Bulk) Source_(sourceconfigparam string) *Bulk
- func (r *Bulk) Timeout(duration string) *Bulk
- func (r *Bulk) UpdateOp(op types.UpdateOperation, doc interface{}, update *types.UpdateAction) error
- func (r *Bulk) WaitForActiveShards(waitforactiveshards string) *Bulk
- type NewBulk
- type Request
- type Response
Constants ¶
This section is empty.
Variables ¶
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 ¶
func New(tp elastictransport.Interface) *Bulk
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 ¶
Do runs the request through the transport, handle the response and returns a bulk.Response
func (*Bulk) HttpRequest ¶
HttpRequest returns the http.Request object built from the given parameters.
func (*Bulk) Index ¶
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 ¶
Perform runs the http.Request through the provided transport and returns an http.Response.
func (*Bulk) Pipeline ¶
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 ¶
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 ¶
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) RequireAlias ¶
RequireAlias If `true`, the request’s actions must target an index alias. API name: require_alias
func (*Bulk) Routing ¶
Routing Custom value used to route operations to a specific shard. API name: routing
func (*Bulk) SourceExcludes_ ¶
SourceExcludes_ A comma-separated list of source fields to exclude from the response. API name: _source_excludes
func (*Bulk) SourceIncludes_ ¶
SourceIncludes_ A comma-separated list of source fields to include in the response. API name: _source_includes
func (*Bulk) Source_ ¶
Source_ `true` or `false` to return the `_source` field or not, or a list of fields to return. API name: _source
func (*Bulk) Timeout ¶
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 ¶
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
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