void sendBulkCommand(BulkRequest bulkRequest, int bulkSize) { if (bulkRequest.numberOfActions() > 0) { if (log.isDebugEnabled()) { logDebugMessageTruncated(String.format( "Index %d docs (%d bytes) in bulk request: curl -XPOST 'http://localhost:9200/_bulk' -d '%s'", bulkRequest.numberOfActions(), bulkSize, bulkRequest.requests().toString()), MAX_CURL_LINE); } BulkResponse response = esa.getClient().bulk(bulkRequest); if (response.hasFailures()) { logBulkFailure(response); } } }
@Override public void append(List<String> jsonEntries) { BulkRequest bulkRequest = new BulkRequest(); for (String json : jsonEntries) { try { String entryId = new JSONObject(json).getString(LOG_ID); if (StringUtils.isBlank(entryId)) { throw new NuxeoException("A json entry has an empty id. entry=" + json); } IndexRequest request = new IndexRequest(getESIndexName(), ElasticSearchConstants.ENTRY_TYPE, entryId); request.source(json, XContentType.JSON); bulkRequest.add(request); } catch (JSONException e) { throw new NuxeoException("Unable to deserialize json entry=" + json, e); } } esClient.bulk(bulkRequest); }
BulkResponse bulkResponse = esClient.bulk(bulkRequest); if (bulkResponse.hasFailures()) { for (BulkItemResponse response : bulkResponse.getItems()) {
esa.getClient().bulk(bulkRequest);