@NotThreadSafe public class BulkContext extends Object implements Closeable
Permits to execute an arbitrary number of requests. Which will internally executed as blocks using the bulk API of Elasticsearch.
Note that this instance isn't threadsafe.
Note that AfterSave
and BaseEntityRef.OnDelete
handlers are not executed!
Modifier | Constructor and Description |
---|---|
protected |
BulkContext(LowLevelClient client)
Creates a new instance using the given client.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the bulk context and executes all statements which are still queued.
|
boolean |
commit()
Forces the execution of a bulk update (if statements are queued).
|
BulkContext |
forceDelete(ElasticEntity entity)
Queues an
BaseMapper.forceDelete(BaseEntity) in the batch context. |
Set<String> |
getFailedIds()
Returns all _id-fields of sub-requests which failed within this bulk request.
|
String |
getFailureMessage()
Returns the failure message for this bulk request.
|
boolean |
isEmpty()
Returns whether any executable commands are queued.
|
BulkContext |
overwrite(ElasticEntity entity)
Queues an
BaseMapper.override(BaseEntity) in the batch context. |
BulkContext |
tryDelete(ElasticEntity entity)
Queues an
BaseMapper.tryDelete(BaseEntity) in the batch context. |
BulkContext |
tryUpdate(ElasticEntity entity)
Queues an
BaseMapper.tryUpdate(BaseEntity) in the batch context. |
protected BulkContext(LowLevelClient client)
client
- the client used to execute the bulk requestsElastic.batch()
public BulkContext tryUpdate(ElasticEntity entity)
BaseMapper.tryUpdate(BaseEntity)
in the batch context.entity
- the entity to create or updatepublic BulkContext overwrite(ElasticEntity entity)
BaseMapper.override(BaseEntity)
in the batch context.entity
- the entity to create or updatepublic BulkContext tryDelete(ElasticEntity entity)
BaseMapper.tryDelete(BaseEntity)
in the batch context.entity
- the entity to deletepublic BulkContext forceDelete(ElasticEntity entity)
BaseMapper.forceDelete(BaseEntity)
in the batch context.entity
- the entity to deletepublic boolean commit()
public Set<String> getFailedIds()
Set
of _ids for which the bulk request failed.public String getFailureMessage()
public boolean isEmpty()
public void close()
close
in interface Closeable
close
in interface AutoCloseable
Copyright © 2018. All rights reserved.