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
-
Fields inherited from class org.elasticsearch.action.ActionRequestBuilder
action, client, request
-
-
Constructor Summary
Constructors Constructor Description GetRequestBuilder(ElasticsearchClient client, GetAction action)GetRequestBuilder(ElasticsearchClient client, GetAction action, String index)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description GetRequestBuildersetFetchSource(boolean fetch)Indicates whether the response should contain the stored _source.GetRequestBuildersetFetchSource(String[] includes, String[] excludes)Indicate that _source should be returned, with an "include" and/or "exclude" set which can include simple wildcard elements.GetRequestBuildersetFetchSource(String include, String exclude)Indicate that _source should be returned, with an "include" and/or "exclude" set which can include simple wildcard elements.GetRequestBuildersetId(String id)Sets the id of the document to fetch.GetRequestBuildersetPreference(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(String routing)Controls the shard routing of the request.GetRequestBuildersetStoredFields(String... fields)Explicitly specify the fields that will be returned.GetRequestBuildersetType(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 Detail
-
GetRequestBuilder
public GetRequestBuilder(ElasticsearchClient client, GetAction action)
-
GetRequestBuilder
public GetRequestBuilder(ElasticsearchClient client, GetAction action, @Nullable String index)
-
-
Method Detail
-
setType
public GetRequestBuilder setType(@Nullable String type)
Sets the type of the document to fetch. If set tonull, will use just the id to fetch the first document matching it.
-
setId
public GetRequestBuilder setId(String id)
Sets the id of the document to fetch.
-
setRouting
public GetRequestBuilder setRouting(String routing)
Controls the shard routing of the request. Using this value to hash the shard and not the id.
-
setPreference
public GetRequestBuilder setPreference(String preference)
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
public GetRequestBuilder setStoredFields(String... fields)
Explicitly specify the fields that will be returned. By default, the_sourcefield will be returned.
-
setFetchSource
public GetRequestBuilder setFetchSource(boolean fetch)
Indicates whether the response should contain the stored _source.- Returns:
- this for chaining
-
setFetchSource
public GetRequestBuilder setFetchSource(@Nullable String include, @Nullable 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 String[] includes, @Nullable 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
public GetRequestBuilder setRefresh(boolean 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.
-
setRealtime
public GetRequestBuilder setRealtime(boolean realtime)
-
setVersion
public GetRequestBuilder setVersion(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.
-
setVersionType
public GetRequestBuilder setVersionType(VersionType versionType)
Sets the versioning type. Defaults toVersionType.INTERNAL.
-
-