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  String id
           
protected  String preference
           
protected  String routing
           
protected  String type
           
 
Fields inherited from class org.elasticsearch.action.support.single.shard.SingleShardOperationRequest
index
 
Constructor Summary
GetRequest(String index)
          Constructs a new get request against the specified index.
GetRequest(String index, String type, String id)
          Constructs a new get request against the specified index with the type and id.
 
Method Summary
 String[] fields()
          Explicitly specify the fields that will be returned.
 GetRequest fields(String... fields)
          Explicitly specify the fields that will be returned.
 String id()
           
 GetRequest id(String id)
          Sets the id of the document to fetch.
 GetRequest index(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.
 GetRequest parent(String parent)
          Sets the parent id of this document.
 String preference()
           
 GetRequest preference(String preference)
          Sets the preference to execute the search.
 void readFrom(StreamInput in)
           
 boolean realtime()
           
 GetRequest realtime(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.
 String routing()
           
 GetRequest routing(String routing)
          Controls the shard routing of the request.
 String toString()
           
 String type()
           
 GetRequest type(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
beforeLocalFork, index, listenerThreaded, operationThreaded
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

type

protected String type

id

protected String id

routing

protected String routing

preference

protected String preference
Constructor Detail

GetRequest

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


GetRequest

public GetRequest(String index,
                  String type,
                  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(String index)
Sets the index of the document to fetch.


type

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


id

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


parent

public GetRequest parent(String parent)
Sets the parent id of this document. Will simply set the routing to this value, as it is only used for routing with delete requests.


routing

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


preference

public GetRequest preference(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 String type()

id

public String id()

routing

public String routing()

preference

public String preference()

fields

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


fields

public 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(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 IOException
Specified by:
readFrom in interface Streamable
Overrides:
readFrom in class SingleShardOperationRequest
Throws:
IOException

writeTo

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

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2009-2012. All Rights Reserved.