Java Code Examples for org.elasticsearch.action.bulk.BulkItemResponse#getResponse()

The following examples show how to use org.elasticsearch.action.bulk.BulkItemResponse#getResponse() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EsBulkResponseSummary.java    From soundwave with Apache License 2.0 5 votes vote down vote up
private String getItemId(BulkItemResponse response) {
  String id = response.getId();
  if (response.getResponse() instanceof UpdateResponse) {
    id = ((UpdateResponse) response.getResponse()).getId();
  } else if (response.getResponse() instanceof IndexResponse) {
    id = ((IndexResponse) response.getResponse()).getId();
  }
  return id;
}
 
Example 2
Source File: BaseElasticSearchIndexBuilder.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
protected void executeBulkRequest(BulkRequestBuilder bulkRequest) {
    BulkResponse bulkResponse = bulkRequest.execute().actionGet();

    getLog().info("Bulk request of batch size: " + bulkRequest.numberOfActions() + " took "
            + bulkResponse.getTookInMillis() + " ms in index builder: " + getName());

    for (BulkItemResponse response : bulkResponse.getItems()) {
        if (response.getResponse() instanceof DeleteResponse) {
            DeleteResponse deleteResponse = response.getResponse();

            if (response.isFailed()) {
                getLog().error("Problem deleting doc: " + response.getId() + " in index builder: " + getName()
                        + " error: " + response.getFailureMessage());
            } else if (!deleteResponse.isFound()) {
                getLog().debug("ES could not find a doc with id: " + deleteResponse.getId()
                        + " to delete in index builder: " + getName());
            } else {
                getLog().debug("ES deleted a doc with id: " + deleteResponse.getId() + " in index builder: "
                        + getName());
            }
        } else if (response.getResponse() instanceof IndexResponse) {
            IndexResponse indexResponse = response.getResponse();

            if (response.isFailed()) {
                getLog().error("Problem updating content for doc: " + response.getId() + " in index builder: "
                        + getName() + " error: " + response.getFailureMessage());
            } else {
                getLog().debug("ES indexed content for doc with id: " + indexResponse.getId()
                        + " in index builder: " + getName());
            }
        }
    }
}
 
Example 3
Source File: DcBulkItemResponseImpl.java    From io with Apache License 2.0 5 votes vote down vote up
/**
 * .
 * @param response .
 * @return .
 */
public static DcBulkItemResponse getInstance(BulkItemResponse response) {
    if (response == null) {
        return null;
    }
    return new DcBulkItemResponseImpl(response.getItemId(), response.getOpType(), response.getResponse());
}
 
Example 4
Source File: DcBulkItemResponseImpl.java    From io with Apache License 2.0 5 votes vote down vote up
/**
 * .
 * @param response .
 * @return .
 */
public static DcBulkItemResponse getInstance(BulkItemResponse response) {
    if (response == null) {
        return null;
    }
    return new DcBulkItemResponseImpl(response.getItemId(), response.getOpType(), response.getResponse());
}
 
Example 5
Source File: BaseElasticSearchIndexBuilder.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
protected void executeBulkRequest(BulkRequestBuilder bulkRequest) {
    BulkResponse bulkResponse = bulkRequest.execute().actionGet();

    getLog().info("Bulk request of batch size: " + bulkRequest.numberOfActions() + " took "
            + bulkResponse.getTookInMillis() + " ms in index builder: " + getName());

    for (BulkItemResponse response : bulkResponse.getItems()) {
        if (response.getResponse() instanceof DeleteResponse) {
            DeleteResponse deleteResponse = response.getResponse();

            if (response.isFailed()) {
                getLog().error("Problem deleting doc: " + response.getId() + " in index builder: " + getName()
                        + " error: " + response.getFailureMessage());
            } else if (!deleteResponse.isFound()) {
                getLog().debug("ES could not find a doc with id: " + deleteResponse.getId()
                        + " to delete in index builder: " + getName());
            } else {
                getLog().debug("ES deleted a doc with id: " + deleteResponse.getId() + " in index builder: "
                        + getName());
            }
        } else if (response.getResponse() instanceof IndexResponse) {
            IndexResponse indexResponse = response.getResponse();

            if (response.isFailed()) {
                getLog().error("Problem updating content for doc: " + response.getId() + " in index builder: "
                        + getName() + " error: " + response.getFailureMessage());
            } else {
                getLog().debug("ES indexed content for doc with id: " + indexResponse.getId()
                        + " in index builder: " + getName());
            }
        }
    }
}