java.lang.Object
org.elasticsearch.action.ActionRequestLazyBuilder<BulkRequest,BulkResponse>
org.elasticsearch.action.bulk.BulkRequestBuilder
- All Implemented Interfaces:
RequestBuilder<BulkRequest,,BulkResponse> WriteRequestBuilder<BulkRequestBuilder>
public class BulkRequestBuilder
extends ActionRequestLazyBuilder<BulkRequest,BulkResponse>
implements WriteRequestBuilder<BulkRequestBuilder>
A bulk request holds an ordered
IndexRequests and DeleteRequests and allows to executes
it in a single batch.-
Field Summary
Fields inherited from class org.elasticsearch.action.ActionRequestLazyBuilder
action, client -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd(byte[] data, int from, int length, String defaultIndex, XContentType xContentType) Adds a framed data in binary formatadd(byte[] data, int from, int length, XContentType xContentType) Adds a framed data in binary formatadd(DeleteRequest request) Deprecated.add(DeleteRequestBuilder request) Adds anDeleteRequestto the list of actions to execute.add(IndexRequest request) Deprecated.useadd(IndexRequestBuilder)insteadadd(IndexRequestBuilder request) Adds anIndexRequestto the list of actions to execute.add(UpdateRequest request) Deprecated.useadd(UpdateRequestBuilder)insteadadd(UpdateRequestBuilder request) Adds anUpdateRequestto the list of actions to execute.intThe number of actions currently in the bulk.request()This method creates the request.setRefreshPolicy(String refreshPolicy) Parse the refresh policy from a string, only modifying it if the string is non null.setRefreshPolicy(WriteRequest.RefreshPolicy refreshPolicy) Should this request trigger a refresh (WriteRequest.RefreshPolicy.IMMEDIATE), wait for a refresh ( WriteRequest.RefreshPolicy.WAIT_UNTIL), or proceed ignore refreshes entirely (WriteRequest.RefreshPolicy.NONE, the default).final BulkRequestBuildersetTimeout(TimeValue timeout) A timeout to wait if the index operation can't be performed immediately.setWaitForActiveShards(int waitForActiveShards) A shortcut forsetWaitForActiveShards(ActiveShardCount)where the numerical shard count is passed in, instead of having to first callActiveShardCount.from(int)to get the ActiveShardCount.setWaitForActiveShards(ActiveShardCount waitForActiveShards) Sets the number of shard copies that must be active before proceeding with the write.Methods inherited from class org.elasticsearch.action.ActionRequestLazyBuilder
execute, execute, get, get
-
Constructor Details
-
BulkRequestBuilder
-
BulkRequestBuilder
-
-
Method Details
-
add
Deprecated.useadd(IndexRequestBuilder)insteadAdds anIndexRequestto the list of actions to execute. Follows the same behavior ofIndexRequest(for example, if no id is provided, one will be generated, or usage of the create flag). -
add
Adds anIndexRequestto the list of actions to execute. Follows the same behavior ofIndexRequest(for example, if no id is provided, one will be generated, or usage of the create flag). -
add
Deprecated.useadd(DeleteRequestBuilder)insteadAdds anDeleteRequestto the list of actions to execute. -
add
Adds anDeleteRequestto the list of actions to execute. -
add
Deprecated.useadd(UpdateRequestBuilder)insteadAdds anUpdateRequestto the list of actions to execute. -
add
Adds anUpdateRequestto the list of actions to execute. -
add
public BulkRequestBuilder add(byte[] data, int from, int length, XContentType xContentType) throws Exception Adds a framed data in binary format- Throws:
Exception
-
add
public BulkRequestBuilder add(byte[] data, int from, int length, @Nullable String defaultIndex, XContentType xContentType) throws Exception Adds a framed data in binary format- Throws:
Exception
-
setWaitForActiveShards
Sets the number of shard copies that must be active before proceeding with the write. SeeReplicationRequest.waitForActiveShards(ActiveShardCount)for details. -
setWaitForActiveShards
A shortcut forsetWaitForActiveShards(ActiveShardCount)where the numerical shard count is passed in, instead of having to first callActiveShardCount.from(int)to get the ActiveShardCount. -
setTimeout
A timeout to wait if the index operation can't be performed immediately. Defaults to1m. -
numberOfActions
public int numberOfActions()The number of actions currently in the bulk. -
pipeline
-
routing
-
setRefreshPolicy
Description copied from interface:WriteRequestBuilderShould this request trigger a refresh (WriteRequest.RefreshPolicy.IMMEDIATE), wait for a refresh ( WriteRequest.RefreshPolicy.WAIT_UNTIL), or proceed ignore refreshes entirely (WriteRequest.RefreshPolicy.NONE, the default).- Specified by:
setRefreshPolicyin interfaceWriteRequestBuilder<BulkRequestBuilder>
-
setRefreshPolicy
Description copied from interface:WriteRequestBuilderParse the refresh policy from a string, only modifying it if the string is non null. Convenient to use with request parsing.- Specified by:
setRefreshPolicyin interfaceWriteRequestBuilder<BulkRequestBuilder>
-
request
Description copied from class:ActionRequestLazyBuilderThis method creates the request. The caller of this method is responsible for calling Request#decRef.- Specified by:
requestin interfaceRequestBuilder<BulkRequest,BulkResponse> - Specified by:
requestin interfaceWriteRequestBuilder<BulkRequestBuilder>- Specified by:
requestin classActionRequestLazyBuilder<BulkRequest,BulkResponse> - Returns:
- A newly-built Request, fully initialized by this builder.
-
add(DeleteRequestBuilder)instead