Package org.elasticsearch.action.get
Class GetRequest
- All Implemented Interfaces:
IndicesRequest
,RealtimeRequest
,Writeable
,org.elasticsearch.core.RefCounted
,TaskAwareRequest
A request to get a document (its source) from an index based on its id. Best created using
Requests.getRequest(String)
.
The operation requires the SingleShardRequest.index()
, type(String)
and id(String)
to be set.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.elasticsearch.transport.TransportRequest
TransportRequest.Empty
Nested classes/interfaces inherited from interface org.elasticsearch.action.IndicesRequest
IndicesRequest.Replaceable
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>
-
Field Summary
Fields inherited from class org.elasticsearch.action.support.single.shard.SingleShardRequest
index, INDICES_OPTIONS
-
Constructor Summary
ConstructorDescriptionGetRequest(String index)
Constructs a new get request against the specified index.GetRequest(String index, String id)
Constructs a new get request against the specified index and document ID.GetRequest(String index, String type, String id)
Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionfetchSourceContext(FetchSourceContext context)
Allows setting theFetchSourceContext
for this request, controlling if and how _source should be returned.id()
Sets the id of the document to fetch.preference(String preference)
Sets the preference to execute the search.boolean
realtime()
realtime(boolean realtime)
boolean
refresh()
refresh(boolean refresh)
Should a refresh be executed before this get operation causing the operation to return the latest value.routing()
Controls the shard routing of the request.String[]
Explicitly specify the stored fields that will be returned.storedFields(String... fields)
Explicitly specify the stored fields that will be returned.toString()
type()
Deprecated.Types are in the process of being removed.Deprecated.Types are in the process of being removed.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.version(long version)
versionType(VersionType versionType)
Sets the versioning type.void
writeTo(StreamOutput out)
Write this into the StreamOutput.Methods inherited from class org.elasticsearch.action.support.single.shard.SingleShardRequest
index, index, indices, indicesOptions, validateNonNullIndex
Methods inherited from class org.elasticsearch.action.ActionRequest
getShouldStoreResult
Methods inherited from class org.elasticsearch.transport.TransportRequest
getParentTask, setParentTask
Methods inherited from class org.elasticsearch.transport.TransportMessage
decRef, incRef, remoteAddress, remoteAddress, tryIncRef
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.elasticsearch.action.IndicesRequest
allowsRemoteIndices, includeDataStreams
Methods inherited from interface org.elasticsearch.tasks.TaskAwareRequest
createTask, getDescription, setParentTask
-
Constructor Details
-
GetRequest
public GetRequest() -
GetRequest
Constructs a new get request against the specified index. Theid(String)
must also be set. -
GetRequest
Deprecated.Types are in the process of being removed, useGetRequest(java.lang.String,java.lang.String)
instead.Constructs a new get request against the specified index with the type and id.- Parameters:
index
- The index to get the document fromtype
- The type of the documentid
- The id of the document
-
GetRequest
Constructs a new get request against the specified index and document ID.- Parameters:
index
- The index to get the document fromid
- The id of the document
-
-
Method Details
-
validate
- Specified by:
validate
in classActionRequest
-
type
Deprecated.Types are in the process of being removed.Sets the type of the document to fetch. -
id
Sets the id of the document to fetch. -
routing
Controls the shard routing of the request. Using this value to hash the shard and not the id. -
preference
Sets the preference to execute the search. Defaults to randomize across shards. Can be set to_local
to prefer local shards or a custom value, which guarantees that the same order will be used across different requests. -
type
Deprecated.Types are in the process of being removed. -
id
-
routing
-
preference
-
fetchSourceContext
Allows setting theFetchSourceContext
for this request, controlling if and how _source should be returned. -
fetchSourceContext
-
storedFields
Explicitly specify the stored fields that will be returned. By default, the_source
field will be returned. -
storedFields
Explicitly specify the stored fields that will be returned. By default, the_source
field will be returned. -
refresh
Should a refresh be executed before this get operation causing the operation to return the latest value. Note, heavy get should not set this totrue
. Defaults tofalse
. -
refresh
public boolean refresh() -
realtime
public boolean realtime() -
realtime
- Specified by:
realtime
in interfaceRealtimeRequest
- Parameters:
realtime
- Controls whether this request should be realtime by reading from the translog.
-
version
public 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. -
version
-
versionType
Sets the versioning type. Defaults toVersionType.INTERNAL
. -
versionType
-
writeTo
Description copied from interface:Writeable
Write this into the StreamOutput.- Specified by:
writeTo
in interfaceWriteable
- Overrides:
writeTo
in classSingleShardRequest<GetRequest>
- Throws:
IOException
-
toString
- Overrides:
toString
in classTransportRequest
-
GetRequest(java.lang.String,java.lang.String)
instead.