Example usage for com.amazonaws.services.cloudsearchdomain.model UploadDocumentsResult getDeletes

List of usage examples for com.amazonaws.services.cloudsearchdomain.model UploadDocumentsResult getDeletes

Introduction

In this page you can find the example usage for com.amazonaws.services.cloudsearchdomain.model UploadDocumentsResult getDeletes.

Prototype


public Long getDeletes() 

Source Link

Document

The number of documents that were deleted from the search domain.

Usage

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);
    }
}