Do we need to close() the bulk request? Or can we just ignore it if we have 0 requests in there?
> if (bulk.numberOfActions() > 0) {
> LOGGER.debug("Elasticsearch Writing [{}]", bulk.request().requests().size());
> BulkResponse bulkResponse = bulk.get();
> if (bulkResponse.hasFailures()) {
> for (BulkItemResponse r : bulkResponse.getItems()) {
> LOGGER.warn("Errors on Bulk Update {}", r.getFailureMessage());
> }
> }
> if (isImmediate) {
> commitTransaction(client, true);
> }
> } else {
> // ANYTHING HERE?
> LOGGER.info("Elasticsearch bulk request was 0 actions");
> }
If you mean BulkRequestBuilder, it is not closable, so you don't need to and and cannot close it.
By the way, have you seen BulkProcessor ? It is typically a good place to start when you are dealing with bulk indexing from java.
Question for you.
We are using:
bulk.add(client.prepareUpdate(newIndexname, documentType, documentId)
.setScript(new Script(ScriptType.INLINE, "painless", "ctx._source." + DATA_FIELD + "." + field + ".remove(ctx._source." + DATA_FIELD + "." + field + ".indexOf(params.val));", params))
.setDetectNoop(false));
Will this work with the Bulk Processor?
There appears to be only these 2 calls with it?
bulkProcessor.add(new IndexRequest("twitter", "tweet", "1").source(/* your doc here */));
bulkProcessor.add(new DeleteRequest("twitter", "tweet", "2"));
The method signature is public BulkProcessor add(DocWriteRequest request)
and DocWriteRequest
is implemented by DeleteRequest
, IndexRequest
, and UpdateRequest
. Did you try it? Did you get any error messages?
system
(system)
Closed
May 4, 2017, 9:46pm
6
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.