Package org.elasticsearch.action
Class DocWriteResponse
- java.lang.Object
-
- All Implemented Interfaces:
WriteResponse
,Streamable
,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 class
DocWriteResponse.Builder
Base class of allDocWriteResponse
builders.static class
DocWriteResponse.Result
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.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.Result
result
-
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 protected
DocWriteResponse()
DocWriteResponse(ShardId shardId, java.lang.String type, java.lang.String id, long seqNo, long primaryTerm, long version, DocWriteResponse.Result result)
-
Method Summary
Modifier and Type Method Description boolean
forcedRefresh()
Did this request force a refresh? Requests that setWriteRequest.setRefreshPolicy(RefreshPolicy)
toWriteRequest.RefreshPolicy.IMMEDIATE
will always return true for this.java.lang.String
getId()
The id of the document changed.java.lang.String
getIndex()
The index the document was changed in.java.lang.String
getLocation(java.lang.String routing)
Return the relative URI for the location of the document suitable for use in theLocation
header.long
getPrimaryTerm()
The primary term for this change.DocWriteResponse.Result
getResult()
The change that occurred to the document.long
getSeqNo()
Returns the sequence number assigned for this change.ShardId
getShardId()
The exact shard the document was changed in.java.lang.String
getType()
The type of the document changed.long
getVersion()
Returns the current version of the doc.XContentBuilder
innerToXContent(XContentBuilder builder, ToXContent.Params params)
protected static void
parseInnerToXContent(XContentParser parser, DocWriteResponse.Builder context)
Parse the output of theinnerToXContent(XContentBuilder, Params)
method.void
readFrom(StreamInput in)
Set this object's fields from a StreamInput.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.RestStatus
status()
returns the rest status for this response (based onReplicationResponse.ShardInfo.status()
XContentBuilder
toXContent(XContentBuilder builder, ToXContent.Params params)
void
writeTo(StreamOutput out)
Write this object's fields to a 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 DocWriteResponse.Result result
-
-
Constructor Detail
-
DocWriteResponse
public DocWriteResponse(ShardId shardId, java.lang.String type, java.lang.String id, long seqNo, long primaryTerm, long version, DocWriteResponse.Result result)
-
DocWriteResponse
protected DocWriteResponse()
-
-
Method Detail
-
getResult
public DocWriteResponse.Result getResult()
The change that occurred to the document.
-
getIndex
public java.lang.String getIndex()
The index the document was changed in.
-
getShardId
public ShardId getShardId()
The exact shard the document was changed in.
-
getType
public java.lang.String getType()
The type of the document changed.
-
getId
public java.lang.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_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
public RestStatus status()
returns the rest status for this response (based onReplicationResponse.ShardInfo.status()
- Specified by:
status
in interfaceStatusToXContentObject
-
getLocation
public java.lang.String getLocation(@Nullable java.lang.String routing)
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
-
readFrom
public void readFrom(StreamInput in) throws java.io.IOException
Description copied from interface:Streamable
Set this object's fields from a StreamInput.- Specified by:
readFrom
in interfaceStreamable
- Overrides:
readFrom
in classReplicationResponse
- Throws:
java.io.IOException
-
writeTo
public void writeTo(StreamOutput out) throws java.io.IOException
Description copied from interface:Streamable
Write this object's fields to a StreamOutput.- Specified by:
writeTo
in interfaceStreamable
- Specified by:
writeTo
in interfaceWriteable
- Overrides:
writeTo
in classReplicationResponse
- Throws:
java.io.IOException
-
toXContent
public final XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
- Specified by:
toXContent
in interfaceToXContent
- Throws:
java.io.IOException
-
innerToXContent
public XContentBuilder innerToXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
- Throws:
java.io.IOException
-
parseInnerToXContent
protected static void parseInnerToXContent(XContentParser parser, DocWriteResponse.Builder context) throws java.io.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:
java.io.IOException
-
-