Package org.elasticsearch.action
Class DocWriteResponse
- All Implemented Interfaces:
WriteResponse
,Writeable
,StatusToXContentObject
,RefCounted
,ToXContent
,ToXContentObject
- Direct Known Subclasses:
DeleteResponse
,IndexResponse
,UpdateResponse
public abstract class DocWriteResponse
extends ReplicationResponse
implements WriteResponse, StatusToXContentObject
A base class for the response of a write operation that involves a single doc
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Base class of allDocWriteResponse
builders.static enum
An enum that represents the results of CRUD operations, primarily used to communicate the type of operation that occurred.Nested classes/interfaces inherited from class org.elasticsearch.action.support.replication.ReplicationResponse
ReplicationResponse.ShardInfo
Nested classes/interfaces inherited from class org.elasticsearch.action.ActionResponse
ActionResponse.Empty
Nested classes/interfaces inherited from interface org.elasticsearch.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>
-
Field Summary
Fields inherited from class org.elasticsearch.action.support.replication.ReplicationResponse
EMPTY
Fields inherited from interface org.elasticsearch.xcontent.ToXContent
EMPTY_PARAMS
-
Constructor Summary
ModifierConstructorDescriptionprotected
Needed for deserialization of single item requests inIndexAction
and BwC deserialization pathDocWriteResponse
(ShardId shardId, String type, String id, long seqNo, long primaryTerm, long version, DocWriteResponse.Result result) protected
DocWriteResponse
(ShardId shardId, StreamInput in) -
Method Summary
Modifier and TypeMethodDescriptionboolean
Did this request force a refresh? Requests that setWriteRequest.setRefreshPolicy(RefreshPolicy)
toWriteRequest.RefreshPolicy.IMMEDIATE
will always return true for this.getId()
The id of the document changed.getIndex()
The index the document was changed in.getLocation
(String routing) Return the relative URI for the location of the document suitable for use in theLocation
header.long
The primary term for this change.The change that occurred to the document.long
getSeqNo()
Returns the sequence number assigned for this change.The exact shard the document was changed in.getType()
Deprecated.Types are in the process of being removed.long
Returns the current version of the doc.innerToXContent
(XContentBuilder builder, ToXContent.Params params) protected static void
parseInnerToXContent
(XContentParser parser, DocWriteResponse.Builder context) Parse the output of theinnerToXContent(XContentBuilder, Params)
method.void
setForcedRefresh
(boolean forcedRefresh) Mark the response as having forced a refresh? Requests that setWriteRequest.setRefreshPolicy(RefreshPolicy)
toWriteRequest.RefreshPolicy.IMMEDIATE
should always mark this as true.status()
returns the rest status for this response (based onReplicationResponse.ShardInfo.status()
final XContentBuilder
toXContent
(XContentBuilder builder, ToXContent.Params params) void
writeThin
(StreamOutput out) void
writeTo
(StreamOutput out) Write this into the StreamOutput.Methods inherited from class org.elasticsearch.action.support.replication.ReplicationResponse
getShardInfo, setShardInfo
Methods inherited from class org.elasticsearch.transport.TransportMessage
decRef, hasReferences, incRef, remoteAddress, remoteAddress, tryIncRef
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.elasticsearch.xcontent.ToXContentObject
isFragment
-
Field Details
-
result
-
-
Constructor Details
-
DocWriteResponse
public DocWriteResponse(ShardId shardId, String type, String id, long seqNo, long primaryTerm, long version, DocWriteResponse.Result result) -
DocWriteResponse
- Throws:
IOException
-
DocWriteResponse
Needed for deserialization of single item requests inIndexAction
and BwC deserialization path- Throws:
IOException
-
-
Method Details
-
getResult
The change that occurred to the document. -
getIndex
The index the document was changed in. -
getShardId
The exact shard the document was changed in. -
getType
Deprecated.Types are in the process of being removed.The type of the document changed. -
getId
The id of the document changed. -
getVersion
public long getVersion()Returns the current version of the doc. -
getSeqNo
public long getSeqNo()Returns the sequence number assigned for this change. ReturnsSequenceNumbers.UNASSIGNED_SEQ_NO
if the operation wasn't performed (i.e., an update operation that resulted in a NOOP). -
getPrimaryTerm
public long getPrimaryTerm()The primary term for this change.- Returns:
- the primary term
-
forcedRefresh
public boolean forcedRefresh()Did this request force a refresh? Requests that setWriteRequest.setRefreshPolicy(RefreshPolicy)
toWriteRequest.RefreshPolicy.IMMEDIATE
will always return true for this. Requests that set it toWriteRequest.RefreshPolicy.WAIT_UNTIL
will only return true here if they run out of refresh listener slots (seeIndexSettings.MAX_REFRESH_LISTENERS_PER_SHARD
). -
setForcedRefresh
public void setForcedRefresh(boolean forcedRefresh) Description copied from interface:WriteResponse
Mark the response as having forced a refresh? Requests that setWriteRequest.setRefreshPolicy(RefreshPolicy)
toWriteRequest.RefreshPolicy.IMMEDIATE
should always mark this as true. Requests that set it toWriteRequest.RefreshPolicy.WAIT_UNTIL
will only set this to true if they run out of refresh listener slots (seeIndexSettings.MAX_REFRESH_LISTENERS_PER_SHARD
).- Specified by:
setForcedRefresh
in interfaceWriteResponse
-
status
returns the rest status for this response (based onReplicationResponse.ShardInfo.status()
- Specified by:
status
in interfaceStatusToXContentObject
-
getLocation
Return the relative URI for the location of the document suitable for use in theLocation
header. The use of relative URIs is permitted as of HTTP/1.1 (cf. https://tools.ietf.org/html/rfc7231#section-7.1.2).- Parameters:
routing
- custom routing ornull
if custom routing is not used- Returns:
- the relative URI for the location of the document
-
writeThin
- Throws:
IOException
-
writeTo
Description copied from interface:Writeable
Write this into the StreamOutput.- Specified by:
writeTo
in interfaceWriteable
- Overrides:
writeTo
in classReplicationResponse
- Throws:
IOException
-
toXContent
public final XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException - Specified by:
toXContent
in interfaceToXContent
- Throws:
IOException
-
innerToXContent
public XContentBuilder innerToXContent(XContentBuilder builder, ToXContent.Params params) throws IOException - Throws:
IOException
-
parseInnerToXContent
protected static void parseInnerToXContent(XContentParser parser, DocWriteResponse.Builder context) throws IOException Parse the output of theinnerToXContent(XContentBuilder, Params)
method. This method is intended to be called by subclasses and must be called multiple times to parse all the information concerningDocWriteResponse
objects. It always parses the current token, updates the given parsing context accordingly if needed and then immediately returns.- Throws:
IOException
-