Class GetResponse

    • Constructor Detail

      • GetResponse

        public GetResponse​(GetResult getResult)
    • Method Detail

      • isExists

        public boolean isExists()
        Does the document exists.
      • getIndex

        public java.lang.String getIndex()
        The index the document was fetched from.
      • getType

        public java.lang.String getType()
        The type of the document.
      • getId

        public java.lang.String getId()
        The id of the document.
      • getVersion

        public long getVersion()
        The version of the doc.
      • getSeqNo

        public long getSeqNo()
        The sequence number assigned to the last operation that has changed this document, if found.
      • getPrimaryTerm

        public long getPrimaryTerm()
        The primary term of the last primary that has changed this document, if found.
      • getSourceAsBytes

        public byte[] getSourceAsBytes()
        The source of the document if exists.
      • getSourceInternal

        public BytesReference getSourceInternal()
        Returns the internal source bytes, as they are returned without munging (for example, might still be compressed).
      • getSourceAsBytesRef

        public BytesReference getSourceAsBytesRef()
        Returns bytes reference, also un compress the source if needed.
      • isSourceEmpty

        public boolean isSourceEmpty()
        Is the source empty (not available) or not.
      • getSourceAsString

        public java.lang.String getSourceAsString()
        The source of the document (as a string).
      • getSource

        public java.util.Map<java.lang.String,​java.lang.Object> getSource()
      • getFields

        public java.util.Map<java.lang.String,​DocumentField> getFields()
      • getField

        public DocumentField getField​(java.lang.String name)
      • fromXContent

        public static GetResponse fromXContent​(XContentParser parser)
                                        throws java.io.IOException
        This method can be used to parse a GetResponse object when it has been printed out as a xcontent using the toXContent(XContentBuilder, Params) method.

        For forward compatibility reason this method might not fail if it tries to parse a field it doesn't know. But before returning the result it will check that enough information were parsed to return a valid GetResponse instance and throws a ParsingException otherwise. This is the case when we get a 404 back, which can be parsed as a normal GetResponse with found set to false, or as an elasticsearch exception. The caller of this method needs a way to figure out whether we got back a valid get response, which can be done by catching ParsingException.

        Parameters:
        parser - XContentParser to parse the response from
        Returns:
        a GetResponse
        Throws:
        java.io.IOException - is an I/O exception occurs during the parsing
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object