update

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: 7

Documentation

Overview

Updates a document with a script or partial document.

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 NewUpdate

type NewUpdate func(index, id string) *Update

NewUpdate type alias for index.

func NewUpdateFunc

func NewUpdateFunc(tp elastictransport.Interface) NewUpdate

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

type Request

type Request struct {

	// DetectNoop Set to false to disable setting 'result' in the response
	// to 'noop' if no change to the document occurred.
	DetectNoop *bool `json:"detect_noop,omitempty"`
	// Doc A partial update to an existing document.
	Doc json.RawMessage `json:"doc,omitempty"`
	// DocAsUpsert Set to true to use the contents of 'doc' as the value of 'upsert'
	DocAsUpsert *bool `json:"doc_as_upsert,omitempty"`
	// Script Script to execute to update the document.
	Script types.Script `json:"script,omitempty"`
	// ScriptedUpsert Set to true to execute the script whether or not the document exists.
	ScriptedUpsert *bool `json:"scripted_upsert,omitempty"`
	// Source_ Set to false to disable source retrieval. You can also specify a
	// comma-separated
	// list of the fields you want to retrieve.
	Source_ types.SourceConfig `json:"_source,omitempty"`
	// Upsert If the document does not already exist, the contents of 'upsert' are inserted
	// as a
	// new document. If the document exists, the 'script' is executed.
	Upsert json.RawMessage `json:"upsert,omitempty"`
}

Request holds the request body struct for the package update

https://github.com/elastic/elasticsearch-specification/blob/5bf86339cd4bda77d07f6eaa6789b72f9c0279b1/specification/_global/update/UpdateRequest.ts#L38-L151

func NewRequest added in v8.5.0

func NewRequest() *Request

NewRequest returns a Request

func (*Request) FromJSON added in v8.5.0

func (r *Request) FromJSON(data string) (*Request, error)

FromJSON allows to load an arbitrary json into the request structure

func (*Request) UnmarshalJSON added in v8.12.1

func (s *Request) UnmarshalJSON(data []byte) error

type Response added in v8.7.0

type Response struct {
	ForcedRefresh *bool                 `json:"forced_refresh,omitempty"`
	Get           *types.InlineGet      `json:"get,omitempty"`
	Id_           string                `json:"_id"`
	Index_        string                `json:"_index"`
	PrimaryTerm_  int64                 `json:"_primary_term"`
	Result        result.Result         `json:"result"`
	SeqNo_        int64                 `json:"_seq_no"`
	Shards_       types.ShardStatistics `json:"_shards"`
	Version_      int64                 `json:"_version"`
}

Response holds the response body struct for the package update

https://github.com/elastic/elasticsearch-specification/blob/5bf86339cd4bda77d07f6eaa6789b72f9c0279b1/specification/_global/update/UpdateResponse.ts#L27-L29

func NewResponse added in v8.7.0

func NewResponse() *Response

NewResponse returns a Response

type Update

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

func New

Updates a document with a script or partial document.

https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html

func (*Update) DetectNoop added in v8.9.0

func (r *Update) DetectNoop(detectnoop bool) *Update

DetectNoop Set to false to disable setting 'result' in the response to 'noop' if no change to the document occurred. API name: detect_noop

func (Update) Do

func (r Update) Do(providedCtx context.Context) (*Response, error)

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

func (*Update) Doc added in v8.9.0

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

Doc A partial update to an existing document. API name: doc

doc should be a json.RawMessage or a structure if a structure is provided, the client will defer a json serialization prior to sending the payload to Elasticsearch.

func (*Update) DocAsUpsert added in v8.9.0

func (r *Update) DocAsUpsert(docasupsert bool) *Update

DocAsUpsert Set to true to use the contents of 'doc' as the value of 'upsert' API name: doc_as_upsert

func (*Update) Header

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

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

func (*Update) HttpRequest

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

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

func (*Update) IfPrimaryTerm

func (r *Update) IfPrimaryTerm(ifprimaryterm string) *Update

IfPrimaryTerm Only perform the operation if the document has this primary term. API name: if_primary_term

func (*Update) IfSeqNo

func (r *Update) IfSeqNo(sequencenumber string) *Update

IfSeqNo Only perform the operation if the document has this sequence number. API name: if_seq_no

func (*Update) Lang

func (r *Update) Lang(lang string) *Update

Lang The script language. API name: lang

func (Update) Perform added in v8.7.0

func (r Update) Perform(providedCtx context.Context) (*http.Response, error)

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

func (*Update) Raw

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

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

func (*Update) Refresh

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

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. API name: refresh

func (*Update) Request

func (r *Update) Request(req *Request) *Update

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

func (*Update) RequireAlias

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

RequireAlias If true, the destination must be an index alias. API name: require_alias

func (*Update) RetryOnConflict

func (r *Update) RetryOnConflict(retryonconflict int) *Update

RetryOnConflict Specify how many times should the operation be retried when a conflict occurs. API name: retry_on_conflict

func (*Update) Routing

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

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

func (*Update) Script added in v8.9.0

func (r *Update) Script(script types.Script) *Update

Script Script to execute to update the document. API name: script

func (*Update) ScriptedUpsert added in v8.9.0

func (r *Update) ScriptedUpsert(scriptedupsert bool) *Update

ScriptedUpsert Set to true to execute the script whether or not the document exists. API name: scripted_upsert

func (*Update) SourceExcludes_

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

SourceExcludes_ Specify the source fields you want to exclude. API name: _source_excludes

func (*Update) SourceIncludes_

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

SourceIncludes_ Specify the source fields you want to retrieve. API name: _source_includes

func (*Update) Source_

func (r *Update) Source_(sourceconfig types.SourceConfig) *Update

Source_ Set to false to disable source retrieval. You can also specify a comma-separated list of the fields you want to retrieve. API name: _source

func (*Update) Timeout

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

Timeout Period to wait for dynamic mapping updates and active shards. This guarantees Elasticsearch waits for at least the timeout before failing. The actual wait time could be longer, particularly when multiple waits occur. API name: timeout

func (*Update) Upsert added in v8.9.0

func (r *Update) Upsert(upsert interface{}) *Update

Upsert If the document does not already exist, the contents of 'upsert' are inserted as a new document. If the document exists, the 'script' is executed. API name: upsert

upsert should be a json.RawMessage or a structure if a structure is provided, the client will defer a json serialization prior to sending the payload to Elasticsearch.

func (*Update) WaitForActiveShards

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

WaitForActiveShards The number of shard copies that must be active before proceeding with the operations. Set to 'all' or any positive integer up to the total number of shards in the index (number_of_replicas+1). Defaults to 1 meaning the primary shard. API name: wait_for_active_shards

Jump to

Keyboard shortcuts

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