Package org.elasticsearch.action.delete
Class DeleteRequest
- java.lang.Object
-
- All Implemented Interfaces:
CompositeIndicesRequest,DocWriteRequest<DeleteRequest>,IndicesRequest,WriteRequest<DeleteRequest>,Streamable,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 usingRequests.deleteRequest(String).The operation requires the
ReplicationRequest.index(),type(String)andid(String)to be set.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.elasticsearch.transport.TransportRequest
TransportRequest.Empty
-
Nested classes/interfaces inherited from interface org.elasticsearch.action.DocWriteRequest
DocWriteRequest.OpType
-
Nested classes/interfaces inherited from interface org.elasticsearch.action.IndicesRequest
IndicesRequest.Replaceable
-
Nested 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 type, java.lang.String id)Constructs a new delete request against the specified index with the type and id.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Stringid()The id of the document to delete.DeleteRequestid(java.lang.String id)Sets the id of the document to delete.DocWriteRequest.OpTypeopType()Get the requested document operation type of the requestjava.lang.Stringparent()Get the parent for this requestDeleteRequestparent(java.lang.String parent)Sets the parent id of this document.voidreadFrom(StreamInput in)Set this object's fields from a StreamInput.java.lang.Stringrouting()Controls the shard routing of the delete request.DeleteRequestrouting(java.lang.String routing)Controls the shard routing of the request.DeleteRequestsetShardId(ShardId shardId)Override this method from ReplicationAction, this is where we are storing our state in the request object (which we really shouldn't do).java.lang.StringtoString()java.lang.Stringtype()The type of the document to delete.DeleteRequesttype(java.lang.String type)Sets the type of the document to delete.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 object's fields to a StreamOutput.-
Methods inherited from class org.elasticsearch.action.support.replication.ReplicatedWriteRequest
getRefreshPolicy, setRefreshPolicy
-
Methods inherited from class org.elasticsearch.action.support.replication.ReplicationRequest
createTask, getDescription, index, index, indices, indicesOptions, onRetry, shardId, timeout, timeout, timeout, waitForActiveShards, waitForActiveShards, waitForActiveShards
-
Methods inherited from class org.elasticsearch.action.ActionRequest
getShouldStoreResult
-
Methods inherited from class org.elasticsearch.transport.TransportRequest
getParentTask, setParentTask
-
Methods inherited from class org.elasticsearch.transport.TransportMessage
remoteAddress, remoteAddress
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.elasticsearch.action.DocWriteRequest
index, indicesOptions
-
Methods inherited from interface org.elasticsearch.action.IndicesRequest
indices
-
Methods inherited from interface org.elasticsearch.tasks.TaskAwareRequest
setParentTask
-
Methods inherited from interface org.elasticsearch.action.support.WriteRequest
setRefreshPolicy
-
-
-
-
Constructor Detail
-
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
public DeleteRequest(java.lang.String index, java.lang.String type, java.lang.String id)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
-
-
Method Detail
-
validate
public ActionRequestValidationException validate()
- Specified by:
validatein interfaceWriteRequest<DeleteRequest>- Overrides:
validatein classReplicationRequest<DeleteRequest>
-
type
public java.lang.String type()
The type of the document to delete.- Specified by:
typein interfaceDocWriteRequest<DeleteRequest>- Returns:
- the type
-
type
public DeleteRequest type(java.lang.String type)
Sets the type of the document to delete.
-
id
public java.lang.String id()
The id of the document to delete.- Specified by:
idin interfaceDocWriteRequest<DeleteRequest>- Returns:
- the id
-
id
public DeleteRequest id(java.lang.String id)
Sets the id of the document to delete.
-
parent
public java.lang.String parent()
Description copied from interface:DocWriteRequestGet the parent for this request- Specified by:
parentin interfaceDocWriteRequest<DeleteRequest>- Returns:
- The parent for this request.
-
parent
public DeleteRequest parent(java.lang.String parent)
Sets the parent id of this document.
-
routing
public DeleteRequest routing(java.lang.String 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
public DeleteRequest version(long 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
public DeleteRequest versionType(VersionType versionType)
Description copied from interface:DocWriteRequestSets the versioning type. Defaults toVersionType.INTERNAL.- Specified by:
versionTypein interfaceDocWriteRequest<DeleteRequest>
-
versionType
public VersionType versionType()
Description copied from interface:DocWriteRequestGet the document version type for this request- Specified by:
versionTypein interfaceDocWriteRequest<DeleteRequest>- Returns:
- the document version type
-
opType
public DocWriteRequest.OpType 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
-
readFrom
public void readFrom(StreamInput in) throws java.io.IOException
Description copied from interface:StreamableSet this object's fields from a StreamInput.- Specified by:
readFromin interfaceStreamable- Overrides:
readFromin classReplicatedWriteRequest<DeleteRequest>- Throws:
java.io.IOException
-
writeTo
public void writeTo(StreamOutput out) throws java.io.IOException
Description copied from interface:StreamableWrite this object's fields to a StreamOutput.- Specified by:
writeToin interfaceStreamable- Specified by:
writeToin interfaceWriteable- Overrides:
writeToin classReplicatedWriteRequest<DeleteRequest>- Throws:
java.io.IOException
-
toString
public java.lang.String toString()
- Specified by:
toStringin classReplicationRequest<DeleteRequest>
-
setShardId
public DeleteRequest setShardId(ShardId shardId)
Override this method from ReplicationAction, this is where we are storing our state in the request object (which we really shouldn't do). Once the transport client goes away we can move away from making this available, but in the meantime this is dangerous to set or use because the DeleteRequest object will always be wrapped in a bulk request envelope, which is where this *should* be set.- Overrides:
setShardIdin classReplicationRequest<DeleteRequest>
-
-