Class DocWriteResponse

All Implemented Interfaces:
WriteResponse, Writeable, org.elasticsearch.common.util.concurrent.RefCounted, StatusToXContentObject, org.elasticsearch.common.xcontent.ToXContent, org.elasticsearch.common.xcontent.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
  • Field Details

  • Constructor Details

    • 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​(ShardId shardId, StreamInput in) throws java.io.IOException
      Throws:
      java.io.IOException
    • DocWriteResponse

      protected DocWriteResponse​(StreamInput in) throws java.io.IOException
      Needed for deserialization of single item requests in IndexAction and BwC deserialization path
      Throws:
      java.io.IOException
  • Method Details

    • 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

      @Deprecated public java.lang.String getType()
      Deprecated.
      Types are in the process of being removed.
      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. Returns SequenceNumbers.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 set WriteRequest.setRefreshPolicy(RefreshPolicy) to WriteRequest.RefreshPolicy.IMMEDIATE will always return true for this. Requests that set it to WriteRequest.RefreshPolicy.WAIT_UNTIL will only return true here if they run out of refresh listener slots (see IndexSettings.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 set WriteRequest.setRefreshPolicy(RefreshPolicy) to WriteRequest.RefreshPolicy.IMMEDIATE should always mark this as true. Requests that set it to WriteRequest.RefreshPolicy.WAIT_UNTIL will only set this to true if they run out of refresh listener slots (see IndexSettings.MAX_REFRESH_LISTENERS_PER_SHARD).
      Specified by:
      setForcedRefresh in interface WriteResponse
    • status

      public RestStatus status()
      returns the rest status for this response (based on ReplicationResponse.ShardInfo.status()
      Specified by:
      status in interface StatusToXContentObject
    • 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 the Location 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 or null if custom routing is not used
      Returns:
      the relative URI for the location of the document
    • writeThin

      public void writeThin​(StreamOutput out) throws java.io.IOException
      Throws:
      java.io.IOException
    • writeTo

      public void writeTo​(StreamOutput out) throws java.io.IOException
      Description copied from interface: Writeable
      Write this into the StreamOutput.
      Specified by:
      writeTo in interface Writeable
      Overrides:
      writeTo in class ReplicationResponse
      Throws:
      java.io.IOException
    • toXContent

      public final org.elasticsearch.common.xcontent.XContentBuilder toXContent​(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws java.io.IOException
      Specified by:
      toXContent in interface org.elasticsearch.common.xcontent.ToXContent
      Throws:
      java.io.IOException
    • innerToXContent

      public org.elasticsearch.common.xcontent.XContentBuilder innerToXContent​(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws java.io.IOException
      Throws:
      java.io.IOException
    • parseInnerToXContent

      protected static void parseInnerToXContent​(org.elasticsearch.common.xcontent.XContentParser parser, DocWriteResponse.Builder context) throws java.io.IOException
      Parse the output of the innerToXContent(XContentBuilder, Params) method. This method is intended to be called by subclasses and must be called multiple times to parse all the information concerning DocWriteResponse objects. It always parses the current token, updates the given parsing context accordingly if needed and then immediately returns.
      Throws:
      java.io.IOException