Package org.elasticsearch.action.bulk
Class BulkRequest
org.elasticsearch.transport.TransportMessage
org.elasticsearch.transport.TransportRequest
org.elasticsearch.action.ActionRequest
org.elasticsearch.action.bulk.BulkRequest
- All Implemented Interfaces:
org.apache.lucene.util.Accountable
,CompositeIndicesRequest
,WriteRequest<BulkRequest>
,Writeable
,org.elasticsearch.core.RefCounted
,TaskAwareRequest
public class BulkRequest
extends ActionRequest
implements CompositeIndicesRequest, WriteRequest<BulkRequest>, org.apache.lucene.util.Accountable
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
Fields inherited from interface org.apache.lucene.util.Accountable
NULL_ACCOUNTABLE
-
Constructor Summary
ConstructorDescriptionglobalIndex)
globalIndex, globalType)
Deprecated.Types are in the process of being removed.BulkRequest(StreamInput in)
-
Method Summary
Modifier and TypeMethodDescriptionadd(byte[] data, int from, int length, defaultIndex, defaultType, org.elasticsearch.common.xcontent.XContentType xContentType)
Deprecated.useadd(byte[], int, int, String, XContentType)
insteadadd(byte[] data, int from, int length, defaultIndex, org.elasticsearch.common.xcontent.XContentType xContentType)
Adds a framed data in binary formatadd(byte[] data, int from, int length, org.elasticsearch.common.xcontent.XContentType xContentType)
Adds a framed data in binary format<DocWriteRequest<?>> requests)
Adds a list of requests to be executed.add(DeleteRequest request)
Adds anDeleteRequest
to 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 anIndexRequest
to the list of actions to execute.add(UpdateRequest request)
Adds anUpdateRequest
to the list of actions to execute.add(BytesReference data, defaultIndex, boolean allowExplicitIndex, org.elasticsearch.common.xcontent.XContentType xContentType)
Adds a framed data in binary formatadd(BytesReference data, defaultIndex, defaultType, boolean allowExplicitIndex, org.elasticsearch.common.xcontent.XContentType xContentType)
Deprecated.add(BytesReference data, defaultIndex, defaultType, defaultRouting, FetchSourceContext defaultFetchSourceContext, defaultPipeline, defaultRequireAlias, boolean allowExplicitIndex, org.elasticsearch.common.xcontent.XContentType xContentType)
Deprecated.add(BytesReference data, defaultIndex, defaultType, org.elasticsearch.common.xcontent.XContentType xContentType)
Deprecated.useadd(BytesReference, String, XContentType)
insteadadd(BytesReference data, defaultIndex, defaultRouting, FetchSourceContext defaultFetchSourceContext, defaultPipeline, boolean allowExplicitIndex, org.elasticsearch.common.xcontent.XContentType xContentType)
add(BytesReference data, defaultIndex, org.elasticsearch.common.xcontent.XContentType xContentType)
Adds a framed data in binary formatlong
The estimated size in bytes of the bulk request.Returns optional description of the request to be displayed by the task manager<>
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
The number of actions in the bulk request.pipeline()
globalPipeline)
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)
long
<DocWriteRequest<?>>
requests()
The list of requests in this bulk request.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)
routing()
globalRouting)
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)
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).org.elasticsearch.core.TimeValue
timeout()
timeout)
A timeout to wait if the index operation can't be performed immediately.timeout(org.elasticsearch.core.TimeValue timeout)
A 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.void
writeTo(StreamOutput out)
Write this into the StreamOutput.Methods inherited from class org.elasticsearch.action.ActionRequest
getShouldStoreResult
Methods inherited from class org.elasticsearch.transport.TransportRequest
getParentTask, setParentTask, toString
Methods inherited from class org.elasticsearch.transport.TransportMessage
decRef, incRef, remoteAddress, remoteAddress, tryIncRef
Methods inherited from class java.lang.
, , , , , , , , ,
Methods inherited from interface org.apache.lucene.util.Accountable
getChildResources
Methods inherited from interface org.elasticsearch.tasks.TaskAwareRequest
createTask, setParentTask
Methods inherited from interface org.elasticsearch.action.support.WriteRequest
setRefreshPolicy
-
Field Details
-
timeout
protected org.elasticsearch.core.TimeValue timeout
-
-
Constructor Details
-
BulkRequest
public BulkRequest() -
BulkRequest
- Throws:
-
BulkRequest
public BulkRequest(@Nullable globalIndex) -
BulkRequest
public BulkRequest(@Nullable globalIndex, @Nullable 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. 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
public <DocWriteRequest<?>> requests)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, org.elasticsearch.common.xcontent.XContentType xContentType) throwsAdds a framed data in binary format- Throws:
-
add
public BulkRequest add(byte[] data, int from, int length, @Nullable defaultIndex, @Nullable defaultType, org.elasticsearch.common.xcontent.XContentType xContentType) throwsDeprecated.useadd(byte[], int, int, String, XContentType)
insteadAdds a framed data in binary format- Throws:
-
add
public BulkRequest add(byte[] data, int from, int length, @Nullable defaultIndex, org.elasticsearch.common.xcontent.XContentType xContentType) throwsAdds a framed data in binary format- Throws:
-
add
public BulkRequest add(BytesReference data, @Nullable defaultIndex, @Nullable defaultType, org.elasticsearch.common.xcontent.XContentType xContentType) throwsDeprecated.useadd(BytesReference, String, XContentType)
insteadAdds a framed data in binary format- Throws:
-
add
public BulkRequest add(BytesReference data, @Nullable defaultIndex, org.elasticsearch.common.xcontent.XContentType xContentType) throwsAdds a framed data in binary format- Throws:
-
add
public BulkRequest add(BytesReference data, @Nullable defaultIndex, @Nullable defaultType, boolean allowExplicitIndex, org.elasticsearch.common.xcontent.XContentType xContentType) throwsDeprecated.Adds a framed data in binary format- Throws:
-
add
public BulkRequest add(BytesReference data, @Nullable defaultIndex, boolean allowExplicitIndex, org.elasticsearch.common.xcontent.XContentType xContentType) throwsAdds a framed data in binary format- Throws:
-
add
public BulkRequest add(BytesReference data, @Nullable defaultIndex, @Nullable defaultRouting, @Nullable FetchSourceContext defaultFetchSourceContext, @Nullable defaultPipeline, boolean allowExplicitIndex, org.elasticsearch.common.xcontent.XContentType xContentType) throws- Throws:
-
add
public BulkRequest add(BytesReference data, @Nullable defaultIndex, @Nullable defaultType, @Nullable defaultRouting, @Nullable FetchSourceContext defaultFetchSourceContext, @Nullable defaultPipeline, @Nullable defaultRequireAlias, boolean allowExplicitIndex, org.elasticsearch.common.xcontent.XContentType xContentType) throwsDeprecated.- Throws:
-
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
public final globalPipeline)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
public final globalRouting)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
public final timeout)A timeout to wait if the index operation can't be performed immediately. Defaults to1m
. -
timeout
public org.elasticsearch.core.TimeValue timeout() -
pipeline
public pipeline() -
routing
public routing() -
requireAlias
public requireAlias() -
requireAlias
public 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)
- Parameters:
globalRequireAlias
- the global default setting- Returns:
- Bulk request with global setting set
-
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:
-
getDescription
public getDescription()Description copied from interface:TaskAwareRequest
Returns optional description of the request to be displayed by the task manager- Specified by:
getDescription
in interfaceTaskAwareRequest
-
ramBytesUsed
public long ramBytesUsed()- Specified by:
ramBytesUsed
in interfaceorg.apache.lucene.util.Accountable
-
getIndices
public <> getIndices()
-