Documentation ¶
Overview ¶
Updates a document with a script or partial document.
Index ¶
- Variables
- type NewUpdate
- type Request
- type Response
- type Update
- func (r *Update) DetectNoop(detectnoop bool) *Update
- func (r Update) Do(providedCtx context.Context) (*Response, error)
- func (r *Update) Doc(doc interface{}) *Update
- func (r *Update) DocAsUpsert(docasupsert bool) *Update
- func (r *Update) Header(key, value string) *Update
- func (r *Update) HttpRequest(ctx context.Context) (*http.Request, error)
- func (r *Update) IfPrimaryTerm(ifprimaryterm string) *Update
- func (r *Update) IfSeqNo(sequencenumber string) *Update
- func (r *Update) Lang(lang string) *Update
- func (r Update) Perform(providedCtx context.Context) (*http.Response, error)
- func (r *Update) Raw(raw io.Reader) *Update
- func (r *Update) Refresh(refresh refresh.Refresh) *Update
- func (r *Update) Request(req *Request) *Update
- func (r *Update) RequireAlias(requirealias bool) *Update
- func (r *Update) RetryOnConflict(retryonconflict int) *Update
- func (r *Update) Routing(routing string) *Update
- func (r *Update) Script(script types.Script) *Update
- func (r *Update) ScriptedUpsert(scriptedupsert bool) *Update
- func (r *Update) SourceExcludes_(fields ...string) *Update
- func (r *Update) SourceIncludes_(fields ...string) *Update
- func (r *Update) Source_(sourceconfig types.SourceConfig) *Update
- func (r *Update) Timeout(duration string) *Update
- func (r *Update) Upsert(upsert interface{}) *Update
- func (r *Update) WaitForActiveShards(waitforactiveshards string) *Update
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 NewUpdate ¶
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
func (*Request) FromJSON ¶ added in v8.5.0
FromJSON allows to load an arbitrary json into the request structure
func (*Request) UnmarshalJSON ¶ added in v8.12.1
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
type Update ¶
type Update struct {
// contains filtered or unexported fields
}
func New ¶
func New(tp elastictransport.Interface) *Update
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
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 ¶
Do runs the request through the transport, handle the response and returns a update.Response
func (*Update) Doc ¶ added in v8.9.0
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
DocAsUpsert Set to true to use the contents of 'doc' as the value of 'upsert' API name: doc_as_upsert
func (*Update) HttpRequest ¶
HttpRequest returns the http.Request object built from the given parameters.
func (*Update) IfPrimaryTerm ¶
IfPrimaryTerm Only perform the operation if the document has this primary term. API name: if_primary_term
func (*Update) IfSeqNo ¶
IfSeqNo Only perform the operation if the document has this sequence number. API name: if_seq_no
func (Update) Perform ¶ added in v8.7.0
Perform runs the http.Request through the provided transport and returns an http.Response.
func (*Update) 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 (*Update) 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. API name: refresh
func (*Update) RequireAlias ¶
RequireAlias If true, the destination must be an index alias. API name: require_alias
func (*Update) RetryOnConflict ¶
RetryOnConflict Specify how many times should the operation be retried when a conflict occurs. API name: retry_on_conflict
func (*Update) Routing ¶
Routing Custom value used to route operations to a specific shard. API name: routing
func (*Update) Script ¶ added in v8.9.0
Script Script to execute to update the document. API name: script
func (*Update) ScriptedUpsert ¶ added in v8.9.0
ScriptedUpsert Set to true to execute the script whether or not the document exists. API name: scripted_upsert
func (*Update) SourceExcludes_ ¶
SourceExcludes_ Specify the source fields you want to exclude. API name: _source_excludes
func (*Update) SourceIncludes_ ¶
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 ¶
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
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 ¶
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