public class GetRequest extends SingleShardRequest<GetRequest> implements RealtimeRequest
Requests.getRequest(String)
.
The operation requires the SingleShardRequest.index()
, type(String)
and id(String)
to be set.
TransportRequest.Empty
IndicesRequest.Replaceable
index, INDICES_OPTIONS
Constructor and Description |
---|
GetRequest() |
GetRequest(java.lang.String index)
Constructs a new get request against the specified index.
|
GetRequest(java.lang.String index,
java.lang.String type,
java.lang.String id)
Constructs a new get request against the specified index with the type and id.
|
Modifier and Type | Method and Description |
---|---|
FetchSourceContext |
fetchSourceContext() |
GetRequest |
fetchSourceContext(FetchSourceContext context)
Allows setting the
FetchSourceContext for this request, controlling if and how _source should be returned. |
java.lang.String |
id() |
GetRequest |
id(java.lang.String id)
Sets the id of the document to fetch.
|
java.lang.String |
parent() |
GetRequest |
parent(java.lang.String parent)
Sets the parent id of this document.
|
java.lang.String |
preference() |
GetRequest |
preference(java.lang.String preference)
Sets the preference to execute the search.
|
void |
readFrom(StreamInput in)
Set this object's fields from a StreamInput.
|
boolean |
realtime() |
GetRequest |
realtime(boolean realtime) |
boolean |
refresh() |
GetRequest |
refresh(boolean refresh)
Should a refresh be executed before this get operation causing the operation to
return the latest value.
|
java.lang.String |
routing() |
GetRequest |
routing(java.lang.String routing)
Controls the shard routing of the request.
|
java.lang.String[] |
storedFields()
Explicitly specify the stored fields that will be returned.
|
GetRequest |
storedFields(java.lang.String... fields)
Explicitly specify the stored fields that will be returned.
|
java.lang.String |
toString() |
java.lang.String |
type() |
GetRequest |
type(java.lang.String type)
Sets the type of the document to fetch.
|
ActionRequestValidationException |
validate() |
long |
version()
Sets the version, which will cause the get operation to only be performed if a matching
version exists and no changes happened on the doc since then.
|
GetRequest |
version(long version) |
VersionType |
versionType() |
GetRequest |
versionType(VersionType versionType)
Sets the versioning type.
|
void |
writeTo(StreamOutput out)
Write this object's fields to a StreamOutput.
|
index, index, indices, indicesOptions, operationThreaded, operationThreaded, validateNonNullIndex
getShouldStoreResult
getParentTask, setParentTask
remoteAddress, remoteAddress
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
createTask, getDescription, setParentTask
public GetRequest()
public GetRequest(java.lang.String index)
type(String)
and id(String)
must be set.public GetRequest(java.lang.String index, java.lang.String type, java.lang.String id)
index
- The index to get the document fromtype
- The type of the documentid
- The id of the documentpublic ActionRequestValidationException validate()
validate
in class ActionRequest
public GetRequest type(@Nullable java.lang.String type)
public GetRequest id(java.lang.String id)
public java.lang.String parent()
public GetRequest parent(java.lang.String parent)
public GetRequest routing(java.lang.String routing)
public GetRequest preference(java.lang.String preference)
public java.lang.String type()
public java.lang.String id()
public java.lang.String routing()
public java.lang.String preference()
public GetRequest fetchSourceContext(FetchSourceContext context)
FetchSourceContext
for this request, controlling if and how _source should be returned.public FetchSourceContext fetchSourceContext()
public GetRequest storedFields(java.lang.String... fields)
public java.lang.String[] storedFields()
public GetRequest refresh(boolean refresh)
public boolean refresh()
public boolean realtime()
public GetRequest realtime(boolean realtime)
realtime
in interface RealtimeRequest
realtime
- Controls whether this request should be realtime by reading from the translog.public long version()
public GetRequest version(long version)
public GetRequest versionType(VersionType versionType)
VersionType.INTERNAL
.public VersionType versionType()
public void readFrom(StreamInput in) throws java.io.IOException
Streamable
readFrom
in interface Streamable
readFrom
in class SingleShardRequest<GetRequest>
java.io.IOException
public void writeTo(StreamOutput out) throws java.io.IOException
Streamable
writeTo
in interface Streamable
writeTo
in class SingleShardRequest<GetRequest>
java.io.IOException
public java.lang.String toString()
toString
in class java.lang.Object