public class BulkRequest extends ActionRequest<BulkRequest> implements CompositeIndicesRequest
IndexRequest
s, DeleteRequest
s and UpdateRequest
s
and allows to executes it in a single batch.
Note that we only support refresh on the bulk request not per item.Client.bulk(BulkRequest)
TransportRequest.Empty
Modifier and Type | Field and Description |
---|---|
protected TimeValue |
timeout |
headers
Constructor and Description |
---|
BulkRequest() |
BulkRequest(ActionRequest request)
Creates a bulk request caused by some other request, which is provided as an
argument so that its headers and context can be copied to the new request
|
Modifier and Type | Method and Description |
---|---|
BulkRequest |
add(ActionRequest... requests)
Adds a list of requests to be executed.
|
BulkRequest |
add(ActionRequest request) |
BulkRequest |
add(ActionRequest request,
Object payload)
Add a request to the current BulkRequest.
|
BulkRequest |
add(byte[] data,
int from,
int length)
Adds a framed data in binary format
|
BulkRequest |
add(byte[] data,
int from,
int length,
String defaultIndex,
String defaultType)
Adds a framed data in binary format
|
BulkRequest |
add(BytesReference data,
String defaultIndex,
String defaultType)
Adds a framed data in binary format
|
BulkRequest |
add(BytesReference data,
String defaultIndex,
String defaultType,
boolean allowExplicitIndex)
Adds a framed data in binary format
|
BulkRequest |
add(BytesReference data,
String defaultIndex,
String defaultType,
String defaultRouting,
String[] defaultFields,
Object payload,
boolean allowExplicitIndex) |
BulkRequest |
add(DeleteRequest request)
Adds an
DeleteRequest to the list of actions to execute. |
BulkRequest |
add(DeleteRequest request,
Object payload) |
BulkRequest |
add(IndexRequest request)
Adds an
IndexRequest to the list of actions to execute. |
BulkRequest |
add(IndexRequest request,
Object payload) |
BulkRequest |
add(Iterable<ActionRequest> requests)
Adds a list of requests to be executed.
|
BulkRequest |
add(UpdateRequest request)
Adds an
UpdateRequest to the list of actions to execute. |
BulkRequest |
add(UpdateRequest request,
Object payload) |
WriteConsistencyLevel |
consistencyLevel() |
BulkRequest |
consistencyLevel(WriteConsistencyLevel consistencyLevel)
Sets the consistency level of write.
|
long |
estimatedSizeInBytes()
The estimated size in bytes of the bulk request.
|
int |
numberOfActions()
The number of actions in the bulk request.
|
List<Object> |
payloads()
The list of optional payloads associated with requests in the same order as the requests.
|
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.
|
List<ActionRequest> |
requests()
The list of requests in this bulk request.
|
List<? extends IndicesRequest> |
subRequests()
Returns the subrequests that a composite request is composed of
|
TimeValue |
timeout() |
BulkRequest |
timeout(String timeout)
A timeout to wait if the index operation can't be performed immediately.
|
BulkRequest |
timeout(TimeValue timeout)
A timeout to wait if the index operation can't be performed immediately.
|
ActionRequestValidationException |
validate() |
void |
writeTo(StreamOutput out) |
createTask, getDescription
remoteAddress, remoteAddress
contextSize, copyContextAndHeadersFrom, copyContextFrom, copyHeadersFrom, getContext, getFromContext, getFromContext, getHeader, getHeaders, hasHeader, hasInContext, isContextEmpty, putAllInContext, putHeader, putInContext
protected TimeValue timeout
public BulkRequest()
public BulkRequest(ActionRequest request)
public BulkRequest add(ActionRequest... requests)
public BulkRequest add(ActionRequest request)
public BulkRequest add(ActionRequest request, @Nullable Object payload)
request
- Request to addpayload
- Optional payloadpublic BulkRequest add(Iterable<ActionRequest> requests)
public BulkRequest add(IndexRequest request)
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).public BulkRequest add(IndexRequest request, @Nullable Object payload)
public BulkRequest add(UpdateRequest request)
UpdateRequest
to the list of actions to execute.public BulkRequest add(UpdateRequest request, @Nullable Object payload)
public BulkRequest add(DeleteRequest request)
DeleteRequest
to the list of actions to execute.public BulkRequest add(DeleteRequest request, @Nullable Object payload)
public List<ActionRequest> requests()
public List<? extends IndicesRequest> subRequests()
CompositeIndicesRequest
subRequests
in interface CompositeIndicesRequest
@Nullable public List<Object> payloads()
Note, if no payloads have been provided, this method will return null (as to conserve memory overhead).
public int numberOfActions()
public long estimatedSizeInBytes()
public BulkRequest add(byte[] data, int from, int length) throws Exception
Exception
public BulkRequest add(byte[] data, int from, int length, @Nullable String defaultIndex, @Nullable String defaultType) throws Exception
Exception
public BulkRequest add(BytesReference data, @Nullable String defaultIndex, @Nullable String defaultType) throws Exception
Exception
public BulkRequest add(BytesReference data, @Nullable String defaultIndex, @Nullable String defaultType, boolean allowExplicitIndex) throws Exception
Exception
public BulkRequest add(BytesReference data, @Nullable String defaultIndex, @Nullable String defaultType, @Nullable String defaultRouting, @Nullable String[] defaultFields, @Nullable Object payload, boolean allowExplicitIndex) throws Exception
Exception
public BulkRequest consistencyLevel(WriteConsistencyLevel consistencyLevel)
WriteConsistencyLevel.DEFAULT
public WriteConsistencyLevel consistencyLevel()
public BulkRequest refresh(boolean refresh)
public boolean refresh()
public final BulkRequest timeout(TimeValue timeout)
public final BulkRequest timeout(String timeout)
public TimeValue timeout()
public ActionRequestValidationException validate()
validate
in class ActionRequest<BulkRequest>
public void readFrom(StreamInput in) throws IOException
readFrom
in interface Streamable
readFrom
in class ActionRequest<BulkRequest>
IOException
public void writeTo(StreamOutput out) throws IOException
writeTo
in interface Streamable
writeTo
in class ActionRequest<BulkRequest>
IOException
Copyright © 2009–2017. All rights reserved.