delete
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Overview¶
Delete a document.
Remove a JSON document from the specified index.
NOTE: You cannot send deletion requests directly to a data stream.To delete a document in a data stream, you must target the backing indexcontaining the document.
**Optimistic concurrency control**
Delete operations can be made conditional and only be performed if the lastmodification to the document was assigned the sequence number and primaryterm specified by the `if_seq_no` and `if_primary_term` parameters.If a mismatch is detected, the operation will result in a`VersionConflictException` and a status code of `409`.
**Versioning**
Each document indexed is versioned.When deleting a document, the version can be specified to make sure therelevant document you are trying to delete is actually being deleted and ithas not changed in the meantime.Every write operation run on a document, deletes included, causes its versionto be incremented.The version number of a deleted document remains available for a short timeafter deletion to allow for control of concurrent operations.The length of time for which a deleted document's version remains availableis determined by the `index.gc_deletes` index setting.
**Routing**
If routing is used during indexing, the routing value also needs to bespecified to delete a document.
If the `_routing` mapping is set to `required` and no routing value isspecified, the delete API throws a `RoutingMissingException` and rejects therequest.
For example:
```DELETE /my-index-000001/_doc/1?routing=shard-1```
This request deletes the document with ID 1, but it is routed based on theuser.The document is not deleted if the correct routing is not specified.
**Distributed**
The delete operation gets hashed into a specific shard ID.It then gets redirected into the primary shard within that ID group andreplicated (if needed) to shard replicas within that ID group.
Index¶
- Variables
- type Delete
- func (r Delete) Do(providedCtx context.Context) (*Response, error)
- func (r *Delete) ErrorTrace(errortrace bool) *Delete
- func (r *Delete) FilterPath(filterpaths ...string) *Delete
- func (r *Delete) Header(key, value string) *Delete
- func (r *Delete) HttpRequest(ctx context.Context) (*http.Request, error)
- func (r *Delete) Human(human bool) *Delete
- func (r *Delete) IfPrimaryTerm(ifprimaryterm string) *Delete
- func (r *Delete) IfSeqNo(sequencenumber string) *Delete
- func (r Delete) IsSuccess(providedCtx context.Context) (bool, error)
- func (r Delete) Perform(providedCtx context.Context) (*http.Response, error)
- func (r *Delete) Pretty(pretty bool) *Delete
- func (r *Delete) Refresh(refresh refresh.Refresh) *Delete
- func (r *Delete) Routing(routing string) *Delete
- func (r *Delete) Timeout(duration string) *Delete
- func (r *Delete) Version(versionnumber string) *Delete
- func (r *Delete) VersionType(versiontype versiontype.VersionType) *Delete
- func (r *Delete) WaitForActiveShards(waitforactiveshards string) *Delete
- type NewDelete
- 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¶
typeDelete¶
type Delete struct {// contains filtered or unexported fields}funcNew¶
func New(tpelastictransport.Interface) *Delete
Delete a document.
Remove a JSON document from the specified index.
NOTE: You cannot send deletion requests directly to a data stream.To delete a document in a data stream, you must target the backing indexcontaining the document.
**Optimistic concurrency control**
Delete operations can be made conditional and only be performed if the lastmodification to the document was assigned the sequence number and primaryterm specified by the `if_seq_no` and `if_primary_term` parameters.If a mismatch is detected, the operation will result in a`VersionConflictException` and a status code of `409`.
**Versioning**
Each document indexed is versioned.When deleting a document, the version can be specified to make sure therelevant document you are trying to delete is actually being deleted and ithas not changed in the meantime.Every write operation run on a document, deletes included, causes its versionto be incremented.The version number of a deleted document remains available for a short timeafter deletion to allow for control of concurrent operations.The length of time for which a deleted document's version remains availableis determined by the `index.gc_deletes` index setting.
**Routing**
If routing is used during indexing, the routing value also needs to bespecified to delete a document.
If the `_routing` mapping is set to `required` and no routing value isspecified, the delete API throws a `RoutingMissingException` and rejects therequest.
For example:
```DELETE /my-index-000001/_doc/1?routing=shard-1```
This request deletes the document with ID 1, but it is routed based on theuser.The document is not deleted if the correct routing is not specified.
**Distributed**
The delete operation gets hashed into a specific shard ID.It then gets redirected into the primary shard within that ID group andreplicated (if needed) to shard replicas within that ID group.
https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete.html
func (Delete)Do¶
Do runs the request through the transport, handle the response and returns a delete.Response
func (*Delete)ErrorTrace¶added inv8.14.0
ErrorTrace When set to `true` Elasticsearch will include the full stack trace of errorswhen they occur.API name: error_trace
func (*Delete)FilterPath¶added inv8.14.0
FilterPath Comma-separated list of filters in dot notation which reduce the responsereturned by Elasticsearch.API name: filter_path
func (*Delete)HttpRequest¶
HttpRequest returns the http.Request object built from thegiven parameters.
func (*Delete)Human¶added inv8.14.0
Human When set to `true` will return statistics in a format suitable for humans.For example `"exists_time": "1h"` for humans and`"eixsts_time_in_millis": 3600000` for computers. When disabled the humanreadable values will be omitted. This makes sense for responses beingconsumedonly by machines.API name: human
func (*Delete)IfPrimaryTerm¶
IfPrimaryTerm Only perform the operation if the document has this primary term.API name: if_primary_term
func (*Delete)IfSeqNo¶
IfSeqNo Only perform the operation if the document has this sequence number.API name: if_seq_no
func (Delete)IsSuccess¶
IsSuccess allows to run a query with a context and retrieve the result as a boolean.This only exists for endpoints without a request payload and allows for quick control flow.
func (Delete)Perform¶added inv8.7.0
Perform runs the http.Request through the provided transport and returns an http.Response.
func (*Delete)Pretty¶added inv8.14.0
Pretty If set to `true` the returned JSON will be "pretty-formatted". Only usethis option for debugging only.API name: pretty
func (*Delete)Refresh¶
Refresh If `true`, Elasticsearch refreshes the affected shards to make this operationvisible to search.If `wait_for`, it waits for a refresh to make this operation visible tosearch.If `false`, it does nothing with refreshes.API name: refresh
func (*Delete)Routing¶
Routing A custom value used to route operations to a specific shard.API name: routing
func (*Delete)Timeout¶
Timeout The period to wait for active shards.
This parameter is useful for situations where the primary shard assigned toperform the delete operation might not be available when the delete operationruns.Some reasons for this might be that the primary shard is currently recoveringfrom a store or undergoing relocation.By default, the delete operation will wait on the primary shard to becomeavailable for up to 1 minute before failing and responding with an error.API name: timeout
func (*Delete)Version¶
Version An explicit version number for concurrency control.It must match the current version of the document for the request to succeed.API name: version
func (*Delete)VersionType¶
func (r *Delete) VersionType(versiontypeversiontype.VersionType) *Delete
VersionType The version type.API name: version_type
func (*Delete)WaitForActiveShards¶
WaitForActiveShards The minimum number of shard copies that must be active before proceeding withthe operation.You can set it to `all` or any positive integer up to the total number ofshards in the index (`number_of_replicas+1`).The default value of `1` means it waits for each primary shard to be active.API name: wait_for_active_shards
typeNewDelete¶
NewDelete type alias for index.
funcNewDeleteFunc¶
func NewDeleteFunc(tpelastictransport.Interface)NewDelete
NewDeleteFunc returns a new instance of Delete with the provided transport.Used in the index of the library this allows to retrieve every apis in once place.
typeResponse¶added inv8.7.0
type Response struct {ForcedRefresh *bool `json:"forced_refresh,omitempty"`// Id_ The unique identifier for the added document.Id_string `json:"_id"`// Index_ The name of the index the document was added to.Index_string `json:"_index"`// PrimaryTerm_ The primary term assigned to the document for the indexing operation.PrimaryTerm_ *int64 `json:"_primary_term,omitempty"`// Result The result of the indexing operation: `created` or `updated`.Resultresult.Result `json:"result"`// SeqNo_ The sequence number assigned to the document for the indexing operation.// Sequence numbers are used to ensure an older version of a document doesn't// overwrite a newer version.SeqNo_ *int64 `json:"_seq_no,omitempty"`// Shards_ Information about the replication process of the operation.Shards_types.ShardStatistics `json:"_shards"`// Version_ The document version, which is incremented each time the document is updated.Version_int64 `json:"_version"`}Response holds the response body struct for the package delete