Package org.elasticsearch.action.delete
Class DeleteRequest
java.lang.Object
- All Implemented Interfaces:
CompositeIndicesRequest,DocWriteRequest<DeleteRequest>,IndicesRequest,WriteRequest<DeleteRequest>,Writeable,TaskAwareRequest
public class DeleteRequest extends ReplicatedWriteRequest<DeleteRequest> implements DocWriteRequest<DeleteRequest>, CompositeIndicesRequest
A request to delete a document from an index based on its type and id. Best created using
Requests.deleteRequest(String).
The operation requires the ReplicationRequest.index(), type(String) and id(String) to
be set.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.elasticsearch.transport.TransportRequest
TransportRequest.EmptyNested classes/interfaces inherited from interface org.elasticsearch.action.DocWriteRequest
DocWriteRequest.OpTypeNested classes/interfaces inherited from interface org.elasticsearch.action.IndicesRequest
IndicesRequest.ReplaceableNested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>Nested classes/interfaces inherited from interface org.elasticsearch.action.support.WriteRequest
WriteRequest.RefreshPolicy -
Field Summary
Fields inherited from class org.elasticsearch.action.support.replication.ReplicationRequest
DEFAULT_TIMEOUT, index, shardId, timeout, waitForActiveShards -
Constructor Summary
Constructors Constructor Description DeleteRequest()DeleteRequest(java.lang.String index)Constructs a new delete request against the specified index.DeleteRequest(java.lang.String index, java.lang.String id)Constructs a new delete request against the specified index and id.DeleteRequest(java.lang.String index, java.lang.String type, java.lang.String id)Deprecated.Types are in the process of being removed.DeleteRequest(StreamInput in) -
Method Summary
Modifier and Type Method Description DeleteRequestdefaultTypeIfNull(java.lang.String defaultType)Deprecated.Types are in the process of being removed.java.lang.Stringid()The id of the document to delete.DeleteRequestid(java.lang.String id)Sets the id of the document to delete.longifPrimaryTerm()If set, only perform this delete request if the document was last modification was assigned this primary term.longifSeqNo()If set, only perform this delete request if the document was last modification was assigned this sequence number.DocWriteRequest.OpTypeopType()Get the requested document operation type of the requestjava.lang.Stringrouting()Controls the shard routing of the delete request.DeleteRequestrouting(java.lang.String routing)Controls the shard routing of the request.DeleteRequestsetIfPrimaryTerm(long term)only perform this delete request if the document was last modification was assigned the given primary term.DeleteRequestsetIfSeqNo(long seqNo)only perform this delete request if the document was last modification was assigned the given sequence number.java.lang.StringtoString()java.lang.Stringtype()Deprecated.Types are in the process of being removed.DeleteRequesttype(java.lang.String type)Deprecated.Types are in the process of being removed.ActionRequestValidationExceptionvalidate()longversion()Get the document version for this requestDeleteRequestversion(long version)Sets the version, which will perform the operation only if a matching version exists and no changes happened on the doc since then.VersionTypeversionType()Get the document version type for this requestDeleteRequestversionType(VersionType versionType)Sets the versioning type.voidwriteTo(StreamOutput out)Write this into the StreamOutput.Methods inherited from class org.elasticsearch.action.support.replication.ReplicatedWriteRequest
getRefreshPolicy, setRefreshPolicyMethods inherited from class org.elasticsearch.action.support.replication.ReplicationRequest
createTask, getDescription, index, index, indices, indicesOptions, onRetry, routedBasedOnClusterVersion, shardId, timeout, timeout, timeout, waitForActiveShards, waitForActiveShards, waitForActiveShardsMethods inherited from class org.elasticsearch.transport.TransportRequest
getParentTask, setParentTaskMethods inherited from class org.elasticsearch.transport.TransportMessage
remoteAddress, remoteAddressMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.elasticsearch.action.DocWriteRequest
index, index, indicesOptions
-
Constructor Details
-
DeleteRequest
- Throws:
java.io.IOException
-
DeleteRequest
public DeleteRequest() -
DeleteRequest
public DeleteRequest(java.lang.String index)Constructs a new delete request against the specified index. Thetype(String)andid(String)must be set. -
DeleteRequest
@Deprecated public DeleteRequest(java.lang.String index, java.lang.String type, java.lang.String id)Deprecated.Types are in the process of being removed. UseDeleteRequest(String, String)instead.Constructs a new delete request against the specified index with the type and id.- Parameters:
index- The index to get the document fromtype- The type of the documentid- The id of the document
-
DeleteRequest
public DeleteRequest(java.lang.String index, java.lang.String id)Constructs a new delete request against the specified index and id.- Parameters:
index- The index to get the document fromid- The id of the document
-
-
Method Details
-
validate
- Specified by:
validatein interfaceWriteRequest<DeleteRequest>- Overrides:
validatein classReplicationRequest<DeleteRequest>
-
type
@Deprecated public java.lang.String type()Deprecated.Types are in the process of being removed.The type of the document to delete.- Specified by:
typein interfaceDocWriteRequest<DeleteRequest>- Returns:
- the type
-
type
Deprecated.Types are in the process of being removed.Sets the type of the document to delete.- Specified by:
typein interfaceDocWriteRequest<DeleteRequest>- Returns:
- the Request
-
defaultTypeIfNull
Deprecated.Types are in the process of being removed.Set the default type supplied to a bulk request if this individual request's type is null or empty- Specified by:
defaultTypeIfNullin interfaceDocWriteRequest<DeleteRequest>- Returns:
- the Request
-
id
public java.lang.String id()The id of the document to delete.- Specified by:
idin interfaceDocWriteRequest<DeleteRequest>- Returns:
- the id
-
id
Sets the id of the document to delete. -
routing
Controls the shard routing of the request. Using this value to hash the shard and not the id.- Specified by:
routingin interfaceDocWriteRequest<DeleteRequest>- Returns:
- the Request
-
routing
public java.lang.String routing()Controls the shard routing of the delete request. Using this value to hash the shard and not the id.- Specified by:
routingin interfaceDocWriteRequest<DeleteRequest>- Returns:
- the Routing
-
version
Description copied from interface:DocWriteRequestSets the version, which will perform the operation only if a matching version exists and no changes happened on the doc since then.- Specified by:
versionin interfaceDocWriteRequest<DeleteRequest>
-
version
public long version()Description copied from interface:DocWriteRequestGet the document version for this request- Specified by:
versionin interfaceDocWriteRequest<DeleteRequest>- Returns:
- the document version
-
versionType
Description copied from interface:DocWriteRequestSets the versioning type. Defaults toVersionType.INTERNAL.- Specified by:
versionTypein interfaceDocWriteRequest<DeleteRequest>
-
ifSeqNo
public long ifSeqNo()If set, only perform this delete request if the document was last modification was assigned this sequence number. If the document last modification was assigned a different sequence number aVersionConflictEngineExceptionwill be thrown.- Specified by:
ifSeqNoin interfaceDocWriteRequest<DeleteRequest>
-
ifPrimaryTerm
public long ifPrimaryTerm()If set, only perform this delete request if the document was last modification was assigned this primary term. If the document last modification was assigned a different term aVersionConflictEngineExceptionwill be thrown.- Specified by:
ifPrimaryTermin interfaceDocWriteRequest<DeleteRequest>
-
setIfSeqNo
only perform this delete request if the document was last modification was assigned the given sequence number. Must be used in combination withsetIfPrimaryTerm(long)If the document last modification was assigned a different sequence number aVersionConflictEngineExceptionwill be thrown.- Specified by:
setIfSeqNoin interfaceDocWriteRequest<DeleteRequest>
-
setIfPrimaryTerm
only perform this delete request if the document was last modification was assigned the given primary term. Must be used in combination withsetIfSeqNo(long)If the document last modification was assigned a different primary term aVersionConflictEngineExceptionwill be thrown.- Specified by:
setIfPrimaryTermin interfaceDocWriteRequest<DeleteRequest>
-
versionType
Description copied from interface:DocWriteRequestGet the document version type for this request- Specified by:
versionTypein interfaceDocWriteRequest<DeleteRequest>- Returns:
- the document version type
-
opType
Description copied from interface:DocWriteRequestGet the requested document operation type of the request- Specified by:
opTypein interfaceDocWriteRequest<DeleteRequest>- Returns:
- the operation type
DocWriteRequest.OpType
-
writeTo
Description copied from interface:WriteableWrite this into the StreamOutput.- Specified by:
writeToin interfaceWriteable- Overrides:
writeToin classReplicatedWriteRequest<DeleteRequest>- Throws:
java.io.IOException
-
toString
public java.lang.String toString()- Specified by:
toStringin classReplicationRequest<DeleteRequest>
-