Java 类com.amazonaws.services.cloudsearchdomain.model.UploadDocumentsResult 实例源码

项目:spring-boot-aws-cloudsearch    文件:CloudSearchClient.java   
public List<UploadDocumentsResult> uploadDocuments(String domainName, List<Document> docs) {
    if (docs.size() == 0) {
        return Collections.emptyList();
    }
    AmazonCloudSearchDomainAsyncClient domainClient = cloudSearchDomainAsyncClients.get(domainName);
    if (domainClient == null) {
        throw new IllegalArgumentException(domainName + " not known");
    }
    List<UploadDocumentsRequest> uploadDocumentsRequests = createUploadDocumentsRequest(docs);
    List<UploadDocumentsResult> uploadDocumentsResults = new ArrayList<>(uploadDocumentsRequests.size());
    for (UploadDocumentsRequest uploadDocumentsRequest : uploadDocumentsRequests) {
        UploadDocumentsResult uploadDocumentsResult = domainClient.uploadDocuments(uploadDocumentsRequest);
        uploadDocumentsResults.add(uploadDocumentsResult);
    }
    return uploadDocumentsResults;
}
项目:spring-boot-aws-cloudsearch    文件:CloudSearchClient.java   
public List<Future<UploadDocumentsResult>> uploadDocumentsAsync(String domainName, List<Document> docs) {
    if (docs.size() == 0) {
        return Collections.emptyList();
    }
    AmazonCloudSearchDomainAsyncClient domainClient = cloudSearchDomainAsyncClients.get(domainName);
    if (domainClient == null) {
        throw new IllegalArgumentException(domainName + " not known");
    }
    List<UploadDocumentsRequest> uploadDocumentsRequests = createUploadDocumentsRequest(docs);
    List<Future<UploadDocumentsResult>> uploadDocumentsResults = new ArrayList<>(uploadDocumentsRequests.size());
    for (UploadDocumentsRequest uploadDocumentsRequest : uploadDocumentsRequests) {
        Future<UploadDocumentsResult> uploadDocumentsResult = domainClient
                .uploadDocumentsAsync(uploadDocumentsRequest);
        uploadDocumentsResults.add(uploadDocumentsResult);
    }
    return uploadDocumentsResults;
}
项目:RekognitionS3Batch    文件:CloudSearchIndexer.java   
@Override
public void process(List<Label> labels, String path) {
    LabelInsertDoc doc = new LabelInsertDoc(labels, path);
    Logger.Debug("Json to push: \n%s", doc.asJson());

    byte[] jsonBytes = doc.asJsonBytes();
    UploadDocumentsRequest pushDoc = getUploadReq(jsonBytes);
    UploadDocumentsResult upRes = searchClient.uploadDocuments(pushDoc);

    Logger.Debug("Indexed %s, %s", path, upRes.getStatus());
}
项目:mcs    文件:MatchmakerCloudSearchServiceController.java   
@RequestMapping(value = "/" + restResourceName , method = RequestMethod.POST, produces = "application/json")
@ResponseStatus(value = HttpStatus.OK)
public @ResponseBody String upsert(@RequestBody List<Matchmaker> jsonDocuments)
    throws Exception {
  UploadDocumentsResult result = null;
  String response = null;
  try {
    result = cloudSearchService.upsert(jsonDocuments);
    response = objectMapper.writeValueAsString(result);
  } catch (Exception e) {
    logger.error("", e);
  }
  return response;
}
项目:GeoCrawler    文件:CloudSearchIndexWriter.java   
@Override
public void commit() throws IOException {

  // nothing to do
  if (numDocsInBatch == 0) {
    return;
  }

  // close the array
  buffer.append(']');

  LOG.info("Sending {} docs to CloudSearch", numDocsInBatch);

  byte[] bb = buffer.toString().getBytes(StandardCharsets.UTF_8);

  if (dumpBatchFilesToTemp) {
    try {
      File temp = File.createTempFile("CloudSearch_", ".json");
      FileUtils.writeByteArrayToFile(temp, bb);
      LOG.info("Wrote batch file {}", temp.getName());
    } catch (IOException e1) {
      LOG.error("Exception while generating batch file", e1);
    } finally {
      // reset buffer and doc counter
      buffer = new StringBuffer(MAX_SIZE_BATCH_BYTES).append('[');
      numDocsInBatch = 0;
    }
    return;
  }
  // not in debug mode
  try (InputStream inputStream = new ByteArrayInputStream(bb)) {
    UploadDocumentsRequest batch = new UploadDocumentsRequest();
    batch.setContentLength((long) bb.length);
    batch.setContentType(ContentType.Applicationjson);
    batch.setDocuments(inputStream);
    UploadDocumentsResult result = client.uploadDocuments(batch);
  } catch (Exception e) {
    LOG.error("Exception while sending batch", e);
    LOG.error(buffer.toString());
  } finally {
    // reset buffer and doc counter
    buffer = new StringBuffer(MAX_SIZE_BATCH_BYTES).append('[');
    numDocsInBatch = 0;
  }
}
项目:mcs    文件:CloudSearchServiceTest.java   
@Test
public void testUpsert() throws Exception {
  List<Matchmaker> matchmakerList = createRandomMatchmaker(1);
  UploadDocumentsResult result = cloudSearchService.upsert(matchmakerList);
  logger.info(result.toString());
}