Package org.elasticsearch.action
Class DocWriteResponse
-
- All Implemented Interfaces:
WriteResponse,Writeable,StatusToXContentObject,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
Nested Classes Modifier and Type Class Description static classDocWriteResponse.BuilderBase class of allDocWriteResponsebuilders.static classDocWriteResponse.ResultAn 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.transport.TransportResponse
TransportResponse.Empty
-
Nested classes/interfaces inherited from interface org.elasticsearch.common.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 Modifier and Type Field Description protected DocWriteResponse.Resultresult-
Fields inherited from class org.elasticsearch.action.support.replication.ReplicationResponse
EMPTY
-
Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedDocWriteResponse(StreamInput in)DocWriteResponse(ShardId shardId, String type, String id, long seqNo, long primaryTerm, long version, DocWriteResponse.Result result)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleanforcedRefresh()Did this request force a refresh? Requests that setWriteRequest.setRefreshPolicy(RefreshPolicy)toWriteRequest.RefreshPolicy.IMMEDIATEwill always return true for this.StringgetId()The id of the document changed.StringgetIndex()The index the document was changed in.StringgetLocation(String routing)Return the relative URI for the location of the document suitable for use in theLocationheader.longgetPrimaryTerm()The primary term for this change.DocWriteResponse.ResultgetResult()The change that occurred to the document.longgetSeqNo()Returns the sequence number assigned for this change.ShardIdgetShardId()The exact shard the document was changed in.StringgetType()Deprecated.Types are in the process of being removed.longgetVersion()Returns the current version of the doc.XContentBuilderinnerToXContent(XContentBuilder builder, ToXContent.Params params)protected static voidparseInnerToXContent(XContentParser parser, DocWriteResponse.Builder context)Parse the output of theinnerToXContent(XContentBuilder, Params)method.voidsetForcedRefresh(boolean forcedRefresh)Mark the response as having forced a refresh? Requests that setWriteRequest.setRefreshPolicy(RefreshPolicy)toWriteRequest.RefreshPolicy.IMMEDIATEshould always mark this as true.RestStatusstatus()returns the rest status for this response (based onReplicationResponse.ShardInfo.status()XContentBuildertoXContent(XContentBuilder builder, ToXContent.Params params)voidwriteTo(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
remoteAddress, remoteAddress
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.elasticsearch.common.xcontent.ToXContentObject
isFragment
-
-
-
-
Field Detail
-
result
protected final DocWriteResponse.Result result
-
-
Constructor Detail
-
DocWriteResponse
public DocWriteResponse(ShardId shardId, String type, String id, long seqNo, long primaryTerm, long version, DocWriteResponse.Result result)
-
DocWriteResponse
protected DocWriteResponse(StreamInput in) throws IOException
- Throws:
IOException
-
-
Method Detail
-
getResult
public DocWriteResponse.Result getResult()
The change that occurred to the document.
-
getIndex
public String getIndex()
The index the document was changed in.
-
getShardId
public ShardId getShardId()
The exact shard the document was changed in.
-
getType
@Deprecated public String getType()
Deprecated.Types are in the process of being removed.The type of the document changed.
-
getId
public String 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_NOif 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.IMMEDIATEwill always return true for this. Requests that set it toWriteRequest.RefreshPolicy.WAIT_UNTILwill 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:WriteResponseMark the response as having forced a refresh? Requests that setWriteRequest.setRefreshPolicy(RefreshPolicy)toWriteRequest.RefreshPolicy.IMMEDIATEshould always mark this as true. Requests that set it toWriteRequest.RefreshPolicy.WAIT_UNTILwill only set this to true if they run out of refresh listener slots (seeIndexSettings.MAX_REFRESH_LISTENERS_PER_SHARD).- Specified by:
setForcedRefreshin interfaceWriteResponse
-
status
public RestStatus status()
returns the rest status for this response (based onReplicationResponse.ShardInfo.status()- Specified by:
statusin interfaceStatusToXContentObject
-
getLocation
public String getLocation(@Nullable String routing)
Return the relative URI for the location of the document suitable for use in theLocationheader. 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 ornullif custom routing is not used- Returns:
- the relative URI for the location of the document
-
writeTo
public void writeTo(StreamOutput out) throws IOException
Description copied from interface:WriteableWrite this into the StreamOutput.- Specified by:
writeToin interfaceWriteable- Overrides:
writeToin classReplicationResponse- Throws:
IOException
-
toXContent
public final XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException
- Specified by:
toXContentin 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 concerningDocWriteResponseobjects. It always parses the current token, updates the given parsing context accordingly if needed and then immediately returns.- Throws:
IOException
-
-