public class GetResponse extends ActionResponse implements java.lang.Iterable<GetField>, ToXContentObject
GetRequest
,
Client.get(GetRequest)
TransportResponse.Empty
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params
EMPTY_PARAMS
Constructor and Description |
---|
GetResponse(GetResult getResult) |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object o) |
static GetResponse |
fromXContent(XContentParser parser)
This method can be used to parse a
GetResponse object when it has been printed out
as a xcontent using the ToXContent.toXContent(XContentBuilder, Params) method. |
GetField |
getField(java.lang.String name) |
java.util.Map<java.lang.String,GetField> |
getFields() |
java.lang.String |
getId()
The id of the document.
|
java.lang.String |
getIndex()
The index the document was fetched from.
|
java.util.Map<java.lang.String,java.lang.Object> |
getSource() |
byte[] |
getSourceAsBytes()
The source of the document if exists.
|
BytesReference |
getSourceAsBytesRef()
Returns bytes reference, also un compress the source if needed.
|
java.util.Map<java.lang.String,java.lang.Object> |
getSourceAsMap()
The source of the document (As a map).
|
java.lang.String |
getSourceAsString()
The source of the document (as a string).
|
BytesReference |
getSourceInternal()
Returns the internal source bytes, as they are returned without munging (for example,
might still be compressed).
|
java.lang.String |
getType()
The type of the document.
|
long |
getVersion()
The version of the doc.
|
int |
hashCode() |
boolean |
isExists()
Does the document exists.
|
boolean |
isSourceEmpty()
Is the source empty (not available) or not.
|
java.util.Iterator<GetField> |
iterator()
Deprecated.
Use
getSource() instead |
void |
readFrom(StreamInput in)
Set this object's fields from a StreamInput.
|
java.lang.String |
toString() |
XContentBuilder |
toXContent(XContentBuilder builder,
ToXContent.Params params) |
void |
writeTo(StreamOutput out)
Write this object's fields to a StreamOutput.
|
remoteAddress, remoteAddress
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
isFragment
public GetResponse(GetResult getResult)
public boolean isExists()
public java.lang.String getIndex()
public java.lang.String getType()
public java.lang.String getId()
public long getVersion()
public byte[] getSourceAsBytes()
public BytesReference getSourceInternal()
public BytesReference getSourceAsBytesRef()
public boolean isSourceEmpty()
public java.lang.String getSourceAsString()
public java.util.Map<java.lang.String,java.lang.Object> getSourceAsMap() throws ElasticsearchParseException
ElasticsearchParseException
public java.util.Map<java.lang.String,java.lang.Object> getSource()
public java.util.Map<java.lang.String,GetField> getFields()
public GetField getField(java.lang.String name)
@Deprecated public java.util.Iterator<GetField> iterator()
getSource()
insteaditerator
in interface java.lang.Iterable<GetField>
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
toXContent
in interface ToXContent
java.io.IOException
public static GetResponse fromXContent(XContentParser parser) throws java.io.IOException
GetResponse
object when it has been printed out
as a xcontent using the ToXContent.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.
parser
- XContentParser
to parse the response fromGetResponse
java.io.IOException
- is an I/O exception occurs during the parsingpublic void readFrom(StreamInput in) throws java.io.IOException
Streamable
readFrom
in interface Streamable
readFrom
in class ActionResponse
java.io.IOException
public void writeTo(StreamOutput out) throws java.io.IOException
Streamable
writeTo
in interface Streamable
writeTo
in class ActionResponse
java.io.IOException
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object