List of usage examples for com.amazonaws.services.cloudsearchdomain.model UploadDocumentsResult getDeletes
public Long getDeletes()
The number of documents that were deleted from the search domain.
From source file:com.norconex.committer.cloudsearch.CloudSearchCommitter.java
License:Apache License
private void uploadBatchToCloudSearch(List<JSONObject> documentBatch) { // Convert the JSON list to String and read it as a stream from memory // (for increased performance), for it to be usable by the AWS // CloudSearch UploadRequest. If memory becomes a concern, consider // streaming to file. // ArrayList.toString() joins the elements in a JSON-compliant way. byte[] bytes; try {//from w ww . java 2 s .c o m bytes = documentBatch.toString().getBytes(CharEncoding.UTF_8); } catch (UnsupportedEncodingException e) { throw new CommitterException("UTF-8 not supported by OS.", e); } try (ByteArrayInputStream is = new ByteArrayInputStream(bytes)) { UploadDocumentsRequest uploadRequest = new UploadDocumentsRequest(); uploadRequest.setContentType("application/json"); uploadRequest.setDocuments(is); uploadRequest.setContentLength((long) bytes.length); ensureAWSClient(); UploadDocumentsResult result = awsClient.uploadDocuments(uploadRequest); LOG.info(result.getAdds() + " Add requests and " + result.getDeletes() + " Delete requests " + "sent to the AWS CloudSearch domain."); } catch (IOException e) { throw new CommitterException("Could not upload request to CloudSearch.", e); } }