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(ctx 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(ctx 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 []interface{}) *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 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/{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 ¶
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) 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 The pipeline id to preprocess incoming documents with 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` 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) RequireAlias ¶
RequireAlias Sets require_alias for all incoming documents. Defaults to unset (false) API name: require_alias
func (*Bulk) SourceExcludes_ ¶
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_ ¶
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_ ¶
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) 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 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"`
}