@Override protected BulkResult createNewElasticSearchResult(BulkResult result, String responseBody, int statusCode, String reasonPhrase, Gson gson) { JsonObject jsonMap = parseResponseBody(responseBody); result.setResponseCode(statusCode); result.setJsonString(responseBody); result.setJsonObject(jsonMap); result.setPathToResult(getPathToResult()); if (isHttpSuccessful(statusCode)) { if(jsonMap.has("errors") && jsonMap.get("errors").getAsBoolean()) { result.setSucceeded(false); result.setErrorMessage("One or more of the items in the Bulk request failed, check BulkResult.getItems() for more information."); log.debug("Bulk operation failed due to one or more failed actions within the Bulk request"); } else { result.setSucceeded(true); log.debug("Bulk operation was successfull"); } } else { result.setSucceeded(false); // provide the generic HTTP status code error, if one hasn't already come in via the JSON response... // eg. // IndicesExist will return 404 (with no content at all) for a missing index, but: // Update will return 404 (with an error message for DocumentMissingException) if (result.getErrorMessage() == null) { result.setErrorMessage(statusCode + " " + (reasonPhrase == null ? "null" : reasonPhrase)); } log.debug("Bulk operation failed with an HTTP error"); } return result; }
@Override protected BulkResult createNewElasticSearchResult(BulkResult result, String responseBody, int statusCode, String reasonPhrase, Gson gson) { JsonObject jsonMap = parseResponseBody(responseBody); result.setResponseCode(statusCode); result.setJsonString(responseBody); result.setJsonObject(jsonMap); result.setPathToResult(getPathToResult()); if (isHttpSuccessful(statusCode)) { if(jsonMap.has("errors") && jsonMap.get("errors").getAsBoolean()) { result.setSucceeded(false); result.setErrorMessage("One or more of the items in the Bulk request failed, check BulkResult.getItems() for more information."); log.debug("Bulk operation failed due to one or more failed actions within the Bulk request"); } else { result.setSucceeded(true); log.debug("Bulk operation was successfull"); } } else { result.setSucceeded(false); // provide the generic HTTP status code error, if one hasn't already come in via the JSON response... // eg. // IndicesExist will return 404 (with no content at all) for a missing index, but: // Update will return 404 (with an error message for DocumentMissingException) if (result.getErrorMessage() == null) { result.setErrorMessage(statusCode + " " + (reasonPhrase == null ? "null" : reasonPhrase)); } log.debug("Bulk operation failed with an HTTP error"); } return result; }
@Override protected BulkResult createNewElasticSearchResult(BulkResult result, String responseBody, int statusCode, String reasonPhrase, ObjectMapper objectMapper) throws IOException { ObjectNode jsonMap = parseResponseBody(responseBody, objectMapper); result.setResponseCode(statusCode); result.setJsonString(responseBody); result.setJsonObject(jsonMap); result.setPathToResult(getPathToResult()); if (isHttpSuccessful(statusCode)) { if(jsonMap.has("errors") && jsonMap.get("errors").asBoolean()) { result.setSucceeded(false); result.setErrorMessage("One or more of the items in the Bulk request failed, check BulkResult.getItems() for more information."); log.debug("Bulk operation failed due to one or more failed actions within the Bulk request"); } else { result.setSucceeded(true); log.debug("Bulk operation was successfull"); } } else { result.setSucceeded(false); // provide the generic HTTP status code error, if one hasn't already come in via the JSON response... // eg. // IndicesExist will return 404 (with no content at all) for a missing index, but: // Update will return 404 (with an error message for DocumentMissingException) if (result.getErrorMessage() == null) { result.setErrorMessage(statusCode + " " + (reasonPhrase == null ? "null" : reasonPhrase)); } log.debug("Bulk operation failed with an HTTP error"); } return result; }