java.lang.Object
org.elasticsearch.transport.TransportMessage
org.elasticsearch.transport.TransportRequest
org.elasticsearch.action.ActionRequest
org.elasticsearch.action.LegacyActionRequest
org.elasticsearch.action.bulk.BulkRequest
- All Implemented Interfaces:
org.apache.lucene.util.Accountable,CompositeIndicesRequest,WriteRequest<BulkRequest>,Writeable,RefCounted,TaskAwareRequest,RawIndexingDataTransportRequest
- Direct Known Subclasses:
SimulateBulkRequest
public class BulkRequest
extends LegacyActionRequest
implements CompositeIndicesRequest, WriteRequest<BulkRequest>, org.apache.lucene.util.Accountable, RawIndexingDataTransportRequest
A bulk request holds an ordered
IndexRequests, DeleteRequests and UpdateRequests
and allows to execute it in a single batch.
Note that we only support refresh on the bulk request not per item.- See Also:
-
Nested Class Summary
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
FieldsFields inherited from interface org.apache.lucene.util.Accountable
NULL_ACCOUNTABLEFields inherited from interface org.elasticsearch.core.RefCounted
ALWAYS_REFERENCED -
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(Iterable<DocWriteRequest<?>> requests) Adds a list of requests to be executed.add(DeleteRequest request) Adds anDeleteRequestto the list of actions to execute.add(DocWriteRequest<?> request) Add a request to the current BulkRequest.add(DocWriteRequest<?>... requests) Adds a list of requests to be executed.add(IndexRequest request) Adds anIndexRequestto the list of actions to execute.add(UpdateRequest request) Adds anUpdateRequestto the list of actions to execute.add(BytesReference data, String defaultIndex, boolean allowExplicitIndex, XContentType xContentType) Adds a framed data in binary formatadd(BytesReference data, String defaultIndex, String defaultRouting, FetchSourceContext defaultFetchSourceContext, String defaultPipeline, Boolean defaultRequireAlias, Boolean defaultRequireDataStream, Boolean defaultListExecutedPipelines, boolean allowExplicitIndex, XContentType xContentType, RestApiVersion restApiVersion) add(BytesReference data, String defaultIndex, XContentType xContentType) Adds a framed data in binary formatlongThe estimated size in bytes of the bulk request.Returns optional description of the request to be displayed by the task managerShould 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).booleanfinal BulkRequestincludeSourceOnError(boolean includeSourceOnError) org.elasticsearch.action.bulk.BulkRequest.IncrementalStatevoidincrementalState(org.elasticsearch.action.bulk.BulkRequest.IncrementalState incrementalState) booleanReturns true if this is a request for a simulation rather than a real bulk request.intThe number of actions in the bulk request.pipeline()final BulkRequestNote for internal callers (NOT high level rest client), the global parameter setting is ignored when used with: -add(IndexRequest)-add(UpdateRequest)-add(DocWriteRequest)-add(DocWriteRequest[]))} -add(Iterable)longList<DocWriteRequest<?>> requests()The list of requests in this bulk request.requireAlias(Boolean globalRequireAlias) Note for internal callers (NOT high level rest client), the global parameter setting is ignored when used with: -add(IndexRequest)-add(UpdateRequest)-add(DocWriteRequest)-add(DocWriteRequest[]))} -add(Iterable)requireDataStream(Boolean globalRequireDatsStream) routing()final BulkRequestNote for internal callers (NOT high level rest client), the global parameter setting is ignored when used with: -add(IndexRequest)-add(UpdateRequest)-add(DocWriteRequest)-add(DocWriteRequest[]))} -add(Iterable)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).timeout()final BulkRequestA timeout to wait if the index operation can't be performed immediately.validate()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.waitForActiveShards(ActiveShardCount waitForActiveShards) Sets the number of shard copies that must be active before proceeding with the write.voidwriteTo(StreamOutput out) Write this into the StreamOutput.Methods inherited from class org.elasticsearch.action.ActionRequest
getShouldStoreResultMethods inherited from class org.elasticsearch.transport.TransportRequest
getParentTask, getRequestId, setParentTask, setRequestId, toStringMethods inherited from class org.elasticsearch.transport.TransportMessage
decRef, hasReferences, incRef, remoteAddress, remoteAddress, tryIncRefMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.lucene.util.Accountable
getChildResourcesMethods inherited from interface org.elasticsearch.transport.RawIndexingDataTransportRequest
isRawIndexingDataMethods inherited from interface org.elasticsearch.core.RefCounted
mustIncRefMethods inherited from interface org.elasticsearch.tasks.TaskAwareRequest
createTask, setParentTaskMethods inherited from interface org.elasticsearch.action.support.WriteRequest
setRefreshPolicy
-
Field Details
-
timeout
-
-
Constructor Details
-
BulkRequest
public BulkRequest() -
BulkRequest
- Throws:
IOException
-
BulkRequest
-
-
Method Details
-
add
Adds a list of requests to be executed. Either index or delete requests. -
add
Add a request to the current BulkRequest. Note for internal callers: This method does not respect all global parameters. Only the global index is applied to the request objects. Global parameters would be respected if the request was serialized for a REST call as it is in the high level rest client.- 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 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 anUpdateRequestto the list of actions to execute. -
add
Adds anDeleteRequestto 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 IOException Adds a framed data in binary format- Throws:
IOException
-
add
public BulkRequest add(byte[] data, int from, int length, @Nullable String defaultIndex, XContentType xContentType) throws IOException Adds a framed data in binary format- Throws:
IOException
-
add
public BulkRequest add(BytesReference data, @Nullable String defaultIndex, XContentType xContentType) throws IOException Adds a framed data in binary format- Throws:
IOException
-
add
public BulkRequest add(BytesReference data, @Nullable String defaultIndex, boolean allowExplicitIndex, XContentType xContentType) throws IOException Adds a framed data in binary format- Throws:
IOException
-
add
public BulkRequest add(BytesReference data, @Nullable String defaultIndex, @Nullable String defaultRouting, @Nullable FetchSourceContext defaultFetchSourceContext, @Nullable String defaultPipeline, @Nullable Boolean defaultRequireAlias, @Nullable Boolean defaultRequireDataStream, @Nullable Boolean defaultListExecutedPipelines, boolean allowExplicitIndex, XContentType xContentType, RestApiVersion restApiVersion) throws IOException - Throws:
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:WriteRequestShould 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 interfaceWriteRequest<BulkRequest>
-
getRefreshPolicy
Description copied from interface:WriteRequestShould 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:
getRefreshPolicyin interfaceWriteRequest<BulkRequest>
-
timeout
A timeout to wait if the index operation can't be performed immediately. Defaults to1m. -
incrementalState
public void incrementalState(org.elasticsearch.action.bulk.BulkRequest.IncrementalState incrementalState) -
includeSourceOnError
-
pipeline
Note for internal callers (NOT high level rest client), the global parameter setting is ignored when used with: -add(IndexRequest)-add(UpdateRequest)-add(DocWriteRequest)-add(DocWriteRequest[]))} -add(Iterable)- Parameters:
globalPipeline- the global default setting- Returns:
- Bulk request with global setting set
-
routing
Note for internal callers (NOT high level rest client), the global parameter setting is ignored when used with: -add(IndexRequest)-add(UpdateRequest)-add(DocWriteRequest)-add(DocWriteRequest[]))} -add(Iterable)- Parameters:
globalRouting- the global default setting- Returns:
- Bulk request with global setting set
-
timeout
-
incrementalState
public org.elasticsearch.action.bulk.BulkRequest.IncrementalState incrementalState() -
pipeline
-
routing
-
requireAlias
-
requireDataStream
-
includeSourceOnError
public boolean includeSourceOnError() -
requireAlias
Note for internal callers (NOT high level rest client), the global parameter setting is ignored when used with: -add(IndexRequest)-add(UpdateRequest)-add(DocWriteRequest)-add(DocWriteRequest[]))} -add(Iterable)- Parameters:
globalRequireAlias- the global default setting- Returns:
- Bulk request with global setting set
-
requireDataStream
-
validate
- Specified by:
validatein interfaceWriteRequest<BulkRequest>- Specified by:
validatein classActionRequest
-
writeTo
Description copied from interface:WriteableWrite this into the StreamOutput.- Specified by:
writeToin interfaceWriteable- Overrides:
writeToin classActionRequest- Throws:
IOException
-
getDescription
Description copied from interface:TaskAwareRequestReturns optional description of the request to be displayed by the task manager- Specified by:
getDescriptionin interfaceTaskAwareRequest
-
ramBytesUsed
public long ramBytesUsed()- Specified by:
ramBytesUsedin interfaceorg.apache.lucene.util.Accountable
-
getIndices
-
isSimulated
public boolean isSimulated()Returns true if this is a request for a simulation rather than a real bulk request.- Returns:
- true if this is a simulated bulk request
-
getComponentTemplateSubstitutions
- Throws:
IOException
-
getIndexTemplateSubstitutions
- Throws:
IOException
-
shallowClone
-