Package org.elasticsearch.action.get
Class GetRequestBuilder
java.lang.Object
org.elasticsearch.action.ActionRequestBuilder<Request,Response>
org.elasticsearch.action.support.single.shard.SingleShardOperationRequestBuilder<GetRequest,GetResponse,GetRequestBuilder>
org.elasticsearch.action.get.GetRequestBuilder
public class GetRequestBuilder extends SingleShardOperationRequestBuilder<GetRequest,GetResponse,GetRequestBuilder>
A get document action request builder.
-
Field Summary
-
Constructor Summary
Constructors Constructor Description GetRequestBuilder(ElasticsearchClient client, GetAction action)GetRequestBuilder(ElasticsearchClient client, GetAction action, java.lang.String index) -
Method Summary
Modifier and Type Method Description GetRequestBuildersetFetchSource(boolean fetch)Indicates whether the response should contain the stored _source.GetRequestBuildersetFetchSource(java.lang.String[] includes, java.lang.String[] excludes)Indicate that _source should be returned, with an "include" and/or "exclude" set which can include simple wildcard elements.GetRequestBuildersetFetchSource(java.lang.String include, java.lang.String exclude)Indicate that _source should be returned, with an "include" and/or "exclude" set which can include simple wildcard elements.GetRequestBuildersetId(java.lang.String id)Sets the id of the document to fetch.GetRequestBuildersetPreference(java.lang.String preference)Sets the preference to execute the search.GetRequestBuildersetRealtime(boolean realtime)GetRequestBuildersetRefresh(boolean refresh)Should a refresh be executed before this get operation causing the operation to return the latest value.GetRequestBuildersetRouting(java.lang.String routing)Controls the shard routing of the request.GetRequestBuildersetStoredFields(java.lang.String... fields)Explicitly specify the fields that will be returned.GetRequestBuildersetType(java.lang.String type)Sets the type of the document to fetch.GetRequestBuildersetVersion(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.GetRequestBuildersetVersionType(VersionType versionType)Sets the versioning type.Methods inherited from class org.elasticsearch.action.support.single.shard.SingleShardOperationRequestBuilder
setIndex
-
Constructor Details
-
GetRequestBuilder
-
GetRequestBuilder
public GetRequestBuilder(ElasticsearchClient client, GetAction action, @Nullable java.lang.String index)
-
-
Method Details
-
setType
Sets the type of the document to fetch. If set tonull, will use just the id to fetch the first document matching it. -
setId
Sets the id of the document to fetch. -
setRouting
Controls the shard routing of the request. Using this value to hash the shard and not the id. -
setPreference
Sets the preference to execute the search. Defaults to randomize across shards. Can be set to_localto prefer local shards or a custom value, which guarantees that the same order will be used across different requests. -
setStoredFields
Explicitly specify the fields that will be returned. By default, the_sourcefield will be returned. -
setFetchSource
Indicates whether the response should contain the stored _source.- Returns:
- this for chaining
-
setFetchSource
public GetRequestBuilder setFetchSource(@Nullable java.lang.String include, @Nullable java.lang.String exclude)Indicate that _source should be returned, with an "include" and/or "exclude" set which can include simple wildcard elements.- Parameters:
include- An optional include (optionally wildcarded) pattern to filter the returned _sourceexclude- An optional exclude (optionally wildcarded) pattern to filter the returned _source
-
setFetchSource
public GetRequestBuilder setFetchSource(@Nullable java.lang.String[] includes, @Nullable java.lang.String[] excludes)Indicate that _source should be returned, with an "include" and/or "exclude" set which can include simple wildcard elements.- Parameters:
includes- An optional list of include (optionally wildcarded) pattern to filter the returned _sourceexcludes- An optional list of exclude (optionally wildcarded) pattern to filter the returned _source
-
setRefresh
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. -
setRealtime
-
setVersion
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. -
setVersionType
Sets the versioning type. Defaults toVersionType.INTERNAL.
-