org.elasticsearch.action.get
Class GetRequest

java.lang.Object
  extended by org.elasticsearch.action.support.single.shard.SingleShardOperationRequest
      extended by org.elasticsearch.action.get.GetRequest
All Implemented Interfaces:
ActionRequest, Streamable

public class GetRequest
extends SingleShardOperationRequest

A request to get a document (its source) from an index based on its type (optional) and id. Best created using Requests.getRequest(String).

The operation requires the SingleShardOperationRequest.index(), type(String) and id(String) to be set.

See Also:
GetResponse, Requests.getRequest(String), Client.get(GetRequest)

Field Summary
protected  java.lang.String id
           
protected  java.lang.String preference
           
protected  java.lang.String routing
           
protected  java.lang.String type
           
 
Fields inherited from class org.elasticsearch.action.support.single.shard.SingleShardOperationRequest
index
 
Constructor Summary
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.
 
Method Summary
 java.lang.String[] fields()
          Explicitly specify the fields that will be returned.
 GetRequest fields(java.lang.String... fields)
          Explicitly specify the fields that will be returned.
 java.lang.String id()
           
 GetRequest id(java.lang.String id)
          Sets the id of the document to fetch.
 GetRequest index(java.lang.String index)
          Sets the index of the document to fetch.
 GetRequest listenerThreaded(boolean threadedListener)
          Should the listener be called on a separate thread if needed.
 GetRequest operationThreaded(boolean threadedOperation)
          Controls if the operation will be executed on a separate thread when executed locally.
 java.lang.String preference()
           
 GetRequest preference(java.lang.String preference)
          Sets the preference to execute the search.
 void readFrom(StreamInput in)
           
 boolean realtime()
           
 GetRequest realtime(java.lang.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 toString()
           
 java.lang.String type()
           
 GetRequest type(java.lang.String type)
          Sets the type of the document to fetch.
 ActionRequestValidationException validate()
           
 void writeTo(StreamOutput out)
           
 
Methods inherited from class org.elasticsearch.action.support.single.shard.SingleShardOperationRequest
index, listenerThreaded, operationThreaded
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

type

protected java.lang.String type

id

protected java.lang.String id

routing

protected java.lang.String routing

preference

protected java.lang.String preference
Constructor Detail

GetRequest

public GetRequest(java.lang.String index)
Constructs a new get request against the specified index. The type(String) and id(String) must be set.


GetRequest

public 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.

Parameters:
index - The index to get the document from
type - The type of the document
id - The id of the document
Method Detail

validate

public ActionRequestValidationException validate()
Specified by:
validate in interface ActionRequest
Overrides:
validate in class SingleShardOperationRequest

index

@Required
public GetRequest index(java.lang.String index)
Sets the index of the document to fetch.


type

public GetRequest type(@Nullable
                       java.lang.String type)
Sets the type of the document to fetch.


id

@Required
public GetRequest id(java.lang.String id)
Sets the id of the document to fetch.


routing

public GetRequest routing(java.lang.String routing)
Controls the shard routing of the request. Using this value to hash the shard and not the id.


preference

public GetRequest preference(java.lang.String preference)
Sets the preference to execute the search. Defaults to randomize across shards. Can be set to _local to prefer local shards, _primary to execute only on primary shards, or a custom value, which guarantees that the same order will be used across different requests.


type

public java.lang.String type()

id

public java.lang.String id()

routing

public java.lang.String routing()

preference

public java.lang.String preference()

fields

public GetRequest fields(java.lang.String... fields)
Explicitly specify the fields that will be returned. By default, the _source field will be returned.


fields

public java.lang.String[] fields()
Explicitly specify the fields that will be returned. By default, the _source field will be returned.


refresh

public GetRequest refresh(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 to true. Defaults to false.


refresh

public boolean refresh()

realtime

public boolean realtime()

realtime

public GetRequest realtime(java.lang.Boolean realtime)

listenerThreaded

public GetRequest listenerThreaded(boolean threadedListener)
Should the listener be called on a separate thread if needed.

Specified by:
listenerThreaded in interface ActionRequest
Overrides:
listenerThreaded in class SingleShardOperationRequest

operationThreaded

public GetRequest operationThreaded(boolean threadedOperation)
Controls if the operation will be executed on a separate thread when executed locally.

Overrides:
operationThreaded in class SingleShardOperationRequest

readFrom

public void readFrom(StreamInput in)
              throws java.io.IOException
Specified by:
readFrom in interface Streamable
Overrides:
readFrom in class SingleShardOperationRequest
Throws:
java.io.IOException

writeTo

public void writeTo(StreamOutput out)
             throws java.io.IOException
Specified by:
writeTo in interface Streamable
Overrides:
writeTo in class SingleShardOperationRequest
Throws:
java.io.IOException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object