use of org.opensearch.client.opensearch.core.bulk.BulkResponseItem in project opensearch-java by opensearch-project.
the class BulkResponse method serializeInternal.
protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
generator.writeKey("errors");
generator.write(this.errors);
if (ApiTypeHelper.isDefined(this.items)) {
generator.writeKey("items");
generator.writeStartArray();
for (BulkResponseItem item0 : this.items) {
item0.serialize(generator, mapper);
}
generator.writeEnd();
}
generator.writeKey("took");
generator.write(this.took);
if (this.ingestTook != null) {
generator.writeKey("ingest_took");
generator.write(this.ingestTook);
}
}
use of org.opensearch.client.opensearch.core.bulk.BulkResponseItem in project opensearch-java by opensearch-project.
the class CrudIT method validateBulkResponses.
private void validateBulkResponses(int nbItems, boolean[] errors, BulkResponse bulkResponse, BulkRequest bulkRequest) {
for (int i = 0; i < nbItems; i++) {
BulkResponseItem bulkResponseItem = bulkResponse.items().get(i);
assertEquals("index", bulkResponseItem.index());
assertEquals("_doc", bulkResponseItem.type());
assertEquals(String.valueOf(i), bulkResponseItem.id());
BulkOperation bulkOperation = bulkRequest.operations().get(i);
if (bulkOperation.isIndex() || bulkOperation.isCreate()) {
assertEquals(errors[i] ? 409 : 201, bulkResponseItem.status());
} else if (bulkOperation.isUpdate()) {
assertEquals(errors[i] ? Result.NotFound.jsonValue() : Result.Updated.jsonValue(), bulkResponseItem.result());
assertEquals(errors[i] ? 404 : 200, bulkResponseItem.status());
} else if (bulkOperation.isDelete()) {
assertEquals(errors[i] ? Result.NotFound.jsonValue() : Result.Deleted.jsonValue(), bulkResponseItem.result());
assertEquals(errors[i] ? 404 : 200, bulkResponseItem.status());
}
}
}
Aggregations