org.elasticsearch.action.bulk
Class BulkRequest

java.lang.Object
  extended by org.elasticsearch.action.bulk.BulkRequest
All Implemented Interfaces:
ActionRequest, Streamable

public class BulkRequest
extends Object
implements ActionRequest

A bulk request holds an ordered IndexRequests and DeleteRequests and allows to executes it in a single batch.

See Also:
Client.bulk(BulkRequest)

Constructor Summary
BulkRequest()
           
 
Method Summary
 BulkRequest add(ActionRequest... requests)
          Adds a list of requests to be executed.
 BulkRequest add(byte[] data, int from, int length, boolean contentUnsafe)
          Adds a framed data in binary format
 BulkRequest add(byte[] data, int from, int length, boolean contentUnsafe, String defaultIndex, String defaultType)
          Adds a framed data in binary format
 BulkRequest add(BytesReference data, boolean contentUnsafe, String defaultIndex, String defaultType)
          Adds a framed data in binary format
 BulkRequest add(DeleteRequest request)
          Adds an DeleteRequest to the list of actions to execute.
 BulkRequest add(IndexRequest request)
          Adds an IndexRequest to the list of actions to execute.
 BulkRequest add(Iterable<ActionRequest> requests)
          Adds a list of requests to be executed.
 WriteConsistencyLevel consistencyLevel()
           
 BulkRequest consistencyLevel(WriteConsistencyLevel consistencyLevel)
          Sets the consistency level of write.
 long estimatedSizeInBytes()
           
 boolean listenerThreaded()
          Should the response listener be executed on a thread or not.
 BulkRequest listenerThreaded(boolean listenerThreaded)
          Sets if the response listener be executed on a thread or not.
 int numberOfActions()
           
 void readFrom(StreamInput in)
           
 boolean refresh()
           
 BulkRequest refresh(boolean refresh)
          Should a refresh be executed post this bulk operation causing the operations to be searchable.
 ReplicationType replicationType()
           
 BulkRequest replicationType(ReplicationType replicationType)
          Set the replication type for this operation.
 List<ActionRequest> requests()
           
 ActionRequestValidationException validate()
           
 void writeTo(StreamOutput out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BulkRequest

public BulkRequest()
Method Detail

add

public BulkRequest add(ActionRequest... requests)
Adds a list of requests to be executed. Either index or delete requests.


add

public BulkRequest add(Iterable<ActionRequest> requests)
Adds a list of requests to be executed. Either index or delete requests.


add

public BulkRequest add(IndexRequest request)
Adds an IndexRequest to the list of actions to execute. Follows the same behavior of IndexRequest (for example, if no id is provided, one will be generated, or usage of the create flag).


add

public BulkRequest add(DeleteRequest request)
Adds an DeleteRequest to the list of actions to execute.


requests

public List<ActionRequest> requests()

numberOfActions

public int numberOfActions()

estimatedSizeInBytes

public long estimatedSizeInBytes()

add

public BulkRequest add(byte[] data,
                       int from,
                       int length,
                       boolean contentUnsafe)
                throws Exception
Adds a framed data in binary format

Throws:
Exception

add

public BulkRequest add(byte[] data,
                       int from,
                       int length,
                       boolean contentUnsafe,
                       @Nullable
                       String defaultIndex,
                       @Nullable
                       String defaultType)
                throws Exception
Adds a framed data in binary format

Throws:
Exception

add

public BulkRequest add(BytesReference data,
                       boolean contentUnsafe,
                       @Nullable
                       String defaultIndex,
                       @Nullable
                       String defaultType)
                throws Exception
Adds a framed data in binary format

Throws:
Exception

consistencyLevel

public BulkRequest consistencyLevel(WriteConsistencyLevel consistencyLevel)
Sets the consistency level of write. Defaults to WriteConsistencyLevel.DEFAULT


consistencyLevel

public WriteConsistencyLevel consistencyLevel()

refresh

public BulkRequest refresh(boolean refresh)
Should a refresh be executed post this bulk operation causing the operations to be searchable. Note, heavy indexing should not set this to true. Defaults to false.


refresh

public boolean refresh()

replicationType

public BulkRequest replicationType(ReplicationType replicationType)
Set the replication type for this operation.


replicationType

public ReplicationType replicationType()

validate

public ActionRequestValidationException validate()
Specified by:
validate in interface ActionRequest

listenerThreaded

public boolean listenerThreaded()
Description copied from interface: ActionRequest
Should the response listener be executed on a thread or not.

When not executing on a thread, it will either be executed on the calling thread, or on an expensive, IO based, thread.

Specified by:
listenerThreaded in interface ActionRequest

listenerThreaded

public BulkRequest listenerThreaded(boolean listenerThreaded)
Description copied from interface: ActionRequest
Sets if the response listener be executed on a thread or not.

Specified by:
listenerThreaded in interface ActionRequest

readFrom

public void readFrom(StreamInput in)
              throws IOException
Specified by:
readFrom in interface Streamable
Throws:
IOException

writeTo

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


Copyright © 2009-2012. All Rights Reserved.