Package org.opensearch.action.get
Class GetResponse
java.lang.Object
org.opensearch.core.transport.TransportMessage
org.opensearch.core.transport.TransportResponse
org.opensearch.core.action.ActionResponse
org.opensearch.action.get.GetResponse
- All Implemented Interfaces:
Iterable<DocumentField>
,org.opensearch.core.common.io.stream.Writeable
,org.opensearch.core.xcontent.ToXContent
,org.opensearch.core.xcontent.ToXContentObject
@PublicApi(since="1.0.0")
public class GetResponse
extends org.opensearch.core.action.ActionResponse
implements Iterable<DocumentField>, org.opensearch.core.xcontent.ToXContentObject
The response of a get action.
- See Also:
- Opensearch.api:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.opensearch.core.transport.TransportResponse
org.opensearch.core.transport.TransportResponse.Empty
Nested classes/interfaces inherited from interface org.opensearch.core.xcontent.ToXContent
org.opensearch.core.xcontent.ToXContent.DelegatingMapParams, org.opensearch.core.xcontent.ToXContent.MapParams, org.opensearch.core.xcontent.ToXContent.Params
Nested classes/interfaces inherited from interface org.opensearch.core.common.io.stream.Writeable
org.opensearch.core.common.io.stream.Writeable.Reader<V>, org.opensearch.core.common.io.stream.Writeable.WriteableRegistry, org.opensearch.core.common.io.stream.Writeable.Writer<V>
-
Field Summary
Fields inherited from interface org.opensearch.core.xcontent.ToXContent
EMPTY_PARAMS
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
static GetResponse
fromXContent
(org.opensearch.core.xcontent.XContentParser parser) This method can be used to parse aGetResponse
object when it has been printed out as a xcontent using thetoXContent(XContentBuilder, Params)
method.getId()
The id of the document.getIndex()
The index the document was fetched from.long
The primary term of the last primary that has changed this document, if found.long
getSeqNo()
The sequence number assigned to the last operation that has changed this document, if found.byte[]
The source of the document if exists.org.opensearch.core.common.bytes.BytesReference
Returns bytes reference, also un compress the source if needed.The source of the document (As a map).The source of the document (as a string).org.opensearch.core.common.bytes.BytesReference
Returns the internal source bytes, as they are returned without munging (for example, might still be compressed).long
The version of the doc.int
hashCode()
boolean
isExists()
Does the document exists.boolean
Is the source empty (not available) or not.iterator()
Deprecated.toString()
org.opensearch.core.xcontent.XContentBuilder
toXContent
(org.opensearch.core.xcontent.XContentBuilder builder, org.opensearch.core.xcontent.ToXContent.Params params) void
writeTo
(org.opensearch.core.common.io.stream.StreamOutput out) Methods inherited from class org.opensearch.core.transport.TransportMessage
remoteAddress, remoteAddress
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface org.opensearch.core.xcontent.ToXContentObject
isFragment
-
Constructor Details
-
GetResponse
-
-
Method Details
-
isExists
public boolean isExists()Does the document exists. -
getIndex
The index the document was fetched from. -
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 org.opensearch.core.common.bytes.BytesReference getSourceInternal()Returns the internal source bytes, as they are returned without munging (for example, might still be compressed). -
getSourceAsBytesRef
public org.opensearch.core.common.bytes.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
The source of the document (as a string). -
getSourceAsMap
The source of the document (As a map).- Throws:
org.opensearch.OpenSearchParseException
-
getSource
-
getFields
-
getField
-
iterator
Deprecated.UsegetSource()
instead- Specified by:
iterator
in interfaceIterable<DocumentField>
-
toXContent
public org.opensearch.core.xcontent.XContentBuilder toXContent(org.opensearch.core.xcontent.XContentBuilder builder, org.opensearch.core.xcontent.ToXContent.Params params) throws IOException - Specified by:
toXContent
in interfaceorg.opensearch.core.xcontent.ToXContent
- Throws:
IOException
-
fromXContent
public static GetResponse fromXContent(org.opensearch.core.xcontent.XContentParser parser) throws IOException This method can be used to parse aGetResponse
object when it has been printed out as a xcontent using thetoXContent(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 aParsingException
otherwise. This is the case when we get a 404 back, which can be parsed as a normalGetResponse
with found set to false, or as an opensearch 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:
IOException
- is an I/O exception occurs during the parsing
-
writeTo
- Specified by:
writeTo
in interfaceorg.opensearch.core.common.io.stream.Writeable
- Throws:
IOException
-
equals
-
hashCode
public int hashCode() -
toString
-
getSource()
instead