org.elasticsearch.action.get
Class GetRequest

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

public class GetRequest
extends SingleOperationRequest

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

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

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

Field Summary
 
Fields inherited from class org.elasticsearch.action.support.single.SingleOperationRequest
id, index, routing, type
 
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.
 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.
 void readFrom(StreamInput in)
           
 boolean refresh()
           
 GetRequest refresh(boolean refresh)
          Should a refresh be executed before this get operation causing the operation to return the latest value.
 GetRequest routing(java.lang.String routing)
          Controls the shard routing of the request.
 java.lang.String toString()
           
 GetRequest type(java.lang.String type)
          Sets the type of the document to fetch.
 void writeTo(StreamOutput out)
           
 
Methods inherited from class org.elasticsearch.action.support.single.SingleOperationRequest
id, index, listenerThreaded, operationThreaded, routing, type, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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

index

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


type

@Required
public GetRequest type(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.


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()

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 SingleOperationRequest

operationThreaded

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

Overrides:
operationThreaded in class SingleOperationRequest

readFrom

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

writeTo

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

toString

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