Package org.elasticsearch.action.bulk
Class BulkRequest
java.lang.Object
org.elasticsearch.transport.TransportMessage
org.elasticsearch.transport.TransportRequest
org.elasticsearch.action.ActionRequest
org.elasticsearch.action.bulk.BulkRequest
- All Implemented Interfaces:
CompositeIndicesRequest
,WriteRequest<BulkRequest>
,Writeable
,TaskAwareRequest
public class BulkRequest extends ActionRequest implements CompositeIndicesRequest, WriteRequest<BulkRequest>
A bulk request holds an ordered
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.- See Also:
Client.bulk(BulkRequest)
-
Nested Class Summary
Nested classes/interfaces inherited from class org.elasticsearch.transport.TransportRequest
TransportRequest.Empty
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>
Nested classes/interfaces inherited from interface org.elasticsearch.action.support.WriteRequest
WriteRequest.RefreshPolicy
-
Field Summary
-
Constructor Summary
Constructors Constructor Description BulkRequest()
BulkRequest(java.lang.String globalIndex)
BulkRequest(java.lang.String globalIndex, java.lang.String globalType)
Deprecated.Types are in the process of being removed.BulkRequest(StreamInput in)
-
Method Summary
Modifier and Type Method Description BulkRequest
add(byte[] data, int from, int length, java.lang.String defaultIndex, java.lang.String defaultType, XContentType xContentType)
Deprecated.useadd(byte[], int, int, String, XContentType)
insteadBulkRequest
add(byte[] data, int from, int length, java.lang.String defaultIndex, XContentType xContentType)
Adds a framed data in binary formatBulkRequest
add(byte[] data, int from, int length, XContentType xContentType)
Adds a framed data in binary formatBulkRequest
add(java.lang.Iterable<DocWriteRequest<?>> requests)
Adds a list of requests to be executed.BulkRequest
add(DeleteRequest request)
Adds anDeleteRequest
to the list of actions to execute.BulkRequest
add(DocWriteRequest<?> request)
Add a request to the current BulkRequest.BulkRequest
add(DocWriteRequest<?>... requests)
Adds a list of requests to be executed.BulkRequest
add(IndexRequest request)
Adds anIndexRequest
to the list of actions to execute.BulkRequest
add(UpdateRequest request)
Adds anUpdateRequest
to the list of actions to execute.BulkRequest
add(BytesReference data, java.lang.String defaultIndex, boolean allowExplicitIndex, XContentType xContentType)
Adds a framed data in binary formatBulkRequest
add(BytesReference data, java.lang.String defaultIndex, java.lang.String defaultType, boolean allowExplicitIndex, XContentType xContentType)
Deprecated.BulkRequest
add(BytesReference data, java.lang.String defaultIndex, java.lang.String defaultType, java.lang.String defaultRouting, FetchSourceContext defaultFetchSourceContext, java.lang.String defaultPipeline, boolean allowExplicitIndex, XContentType xContentType)
Deprecated.BulkRequest
add(BytesReference data, java.lang.String defaultIndex, java.lang.String defaultType, XContentType xContentType)
Deprecated.useadd(BytesReference, String, XContentType)
insteadBulkRequest
add(BytesReference data, java.lang.String defaultIndex, java.lang.String defaultRouting, FetchSourceContext defaultFetchSourceContext, java.lang.String defaultPipeline, boolean allowExplicitIndex, XContentType xContentType)
BulkRequest
add(BytesReference data, java.lang.String defaultIndex, XContentType xContentType)
Adds a framed data in binary formatlong
estimatedSizeInBytes()
The estimated size in bytes of the bulk request.java.lang.String
getDescription()
Returns optional description of the request to be displayed by the task managerWriteRequest.RefreshPolicy
getRefreshPolicy()
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).int
numberOfActions()
The number of actions in the bulk request.java.lang.String
pipeline()
BulkRequest
pipeline(java.lang.String globalPipeline)
java.util.List<DocWriteRequest<?>>
requests()
The list of requests in this bulk request.java.lang.String
routing()
BulkRequest
routing(java.lang.String globalRouting)
BulkRequest
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).TimeValue
timeout()
BulkRequest
timeout(java.lang.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()
ActiveShardCount
waitForActiveShards()
BulkRequest
waitForActiveShards(int waitForActiveShards)
A shortcut forwaitForActiveShards(ActiveShardCount)
where the numerical shard count is passed in, instead of having to first callActiveShardCount.from(int)
to get the ActiveShardCount.BulkRequest
waitForActiveShards(ActiveShardCount waitForActiveShards)
Sets the number of shard copies that must be active before proceeding with the write.void
writeTo(StreamOutput out)
Write this into the StreamOutput.Methods inherited from class org.elasticsearch.transport.TransportRequest
getParentTask, setParentTask
Methods inherited from class org.elasticsearch.transport.TransportMessage
remoteAddress, remoteAddress
-
Field Details
-
Constructor Details
-
BulkRequest
public BulkRequest() -
BulkRequest
- Throws:
java.io.IOException
-
BulkRequest
-
BulkRequest
@Deprecated public BulkRequest(@Nullable java.lang.String globalIndex, @Nullable java.lang.String globalType)Deprecated.Types are in the process of being removed. UseBulkRequest(String)
instead
-
-
Method Details
-
add
Adds a list of requests to be executed. Either index or delete requests. -
add
Add a request to the current BulkRequest.- Parameters:
request
- Request to add- Returns:
- the current bulk request
-
add
Adds a list of requests to be executed. Either index or delete requests. -
add
Adds anIndexRequest
to 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 anUpdateRequest
to the list of actions to execute. -
add
Adds anDeleteRequest
to the list of actions to execute. -
requests
The list of requests in this bulk request. -
numberOfActions
public int numberOfActions()The number of actions in the bulk request. -
estimatedSizeInBytes
public long estimatedSizeInBytes()The estimated size in bytes of the bulk request. -
add
public BulkRequest add(byte[] data, int from, int length, XContentType xContentType) throws java.io.IOExceptionAdds a framed data in binary format- Throws:
java.io.IOException
-
add
@Deprecated public BulkRequest add(byte[] data, int from, int length, @Nullable java.lang.String defaultIndex, @Nullable java.lang.String defaultType, XContentType xContentType) throws java.io.IOExceptionDeprecated.useadd(byte[], int, int, String, XContentType)
insteadAdds a framed data in binary format- Throws:
java.io.IOException
-
add
public BulkRequest add(byte[] data, int from, int length, @Nullable java.lang.String defaultIndex, XContentType xContentType) throws java.io.IOExceptionAdds a framed data in binary format- Throws:
java.io.IOException
-
add
@Deprecated public BulkRequest add(BytesReference data, @Nullable java.lang.String defaultIndex, @Nullable java.lang.String defaultType, XContentType xContentType) throws java.io.IOExceptionDeprecated.useadd(BytesReference, String, XContentType)
insteadAdds a framed data in binary format- Throws:
java.io.IOException
-
add
public BulkRequest add(BytesReference data, @Nullable java.lang.String defaultIndex, XContentType xContentType) throws java.io.IOExceptionAdds a framed data in binary format- Throws:
java.io.IOException
-
add
@Deprecated public BulkRequest add(BytesReference data, @Nullable java.lang.String defaultIndex, @Nullable java.lang.String defaultType, boolean allowExplicitIndex, XContentType xContentType) throws java.io.IOExceptionDeprecated.Adds a framed data in binary format- Throws:
java.io.IOException
-
add
public BulkRequest add(BytesReference data, @Nullable java.lang.String defaultIndex, boolean allowExplicitIndex, XContentType xContentType) throws java.io.IOExceptionAdds a framed data in binary format- Throws:
java.io.IOException
-
add
public BulkRequest add(BytesReference data, @Nullable java.lang.String defaultIndex, @Nullable java.lang.String defaultRouting, @Nullable FetchSourceContext defaultFetchSourceContext, @Nullable java.lang.String defaultPipeline, boolean allowExplicitIndex, XContentType xContentType) throws java.io.IOException- Throws:
java.io.IOException
-
add
@Deprecated public BulkRequest add(BytesReference data, @Nullable java.lang.String defaultIndex, @Nullable java.lang.String defaultType, @Nullable java.lang.String defaultRouting, @Nullable FetchSourceContext defaultFetchSourceContext, @Nullable java.lang.String defaultPipeline, boolean allowExplicitIndex, XContentType xContentType) throws java.io.IOExceptionDeprecated.- Throws:
java.io.IOException
-
waitForActiveShards
Sets the number of shard copies that must be active before proceeding with the write. SeeReplicationRequest.waitForActiveShards(ActiveShardCount)
for details. -
waitForActiveShards
A shortcut forwaitForActiveShards(ActiveShardCount)
where the numerical shard count is passed in, instead of having to first callActiveShardCount.from(int)
to get the ActiveShardCount. -
waitForActiveShards
-
setRefreshPolicy
Description copied from interface:WriteRequest
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).- Specified by:
setRefreshPolicy
in interfaceWriteRequest<BulkRequest>
-
getRefreshPolicy
Description copied from interface:WriteRequest
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).- Specified by:
getRefreshPolicy
in interfaceWriteRequest<BulkRequest>
-
timeout
A timeout to wait if the index operation can't be performed immediately. Defaults to1m
. -
pipeline
-
routing
-
timeout
A timeout to wait if the index operation can't be performed immediately. Defaults to1m
. -
timeout
-
pipeline
public java.lang.String pipeline() -
routing
public java.lang.String routing() -
validate
- Specified by:
validate
in interfaceWriteRequest<BulkRequest>
- Specified by:
validate
in classActionRequest
-
writeTo
Description copied from interface:Writeable
Write this into the StreamOutput.- Specified by:
writeTo
in interfaceWriteable
- Overrides:
writeTo
in classActionRequest
- Throws:
java.io.IOException
-
getDescription
public java.lang.String getDescription()Description copied from interface:TaskAwareRequest
Returns optional description of the request to be displayed by the task manager- Specified by:
getDescription
in interfaceTaskAwareRequest
-