From 298099a4e67c5a132e2d4fbf481eb071da4a7892 Mon Sep 17 00:00:00 2001 From: Erik de Vries Date: Wed, 24 Apr 2019 17:05:20 +0200 Subject: [PATCH] actorizer: fix to deal with empty updates (ie dont do an update) --- R/actorizer.R | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/R/actorizer.R b/R/actorizer.R index 0442dce..6a09c9b 100644 --- a/R/actorizer.R +++ b/R/actorizer.R @@ -137,7 +137,13 @@ actorizer <- function(out, localhost = F, ids, prefix, postfix, pre_tags, post_t post_tags_regex = post_tags_regex, post_tags = post_tags, mc.cores = detectCores())) - bulk <- apply(updates, 1, bulk_writer, varname ='actorsDetail', type = 'add', ver = ver) - bulk <- c(bulk,apply(updates[c(1,11)], 1, bulk_writer, varname='actors', type = 'add', ver = ver)) - return(elastic_update(bulk, es_super = es_super, localhost = localhost)) + if (nrow(updates) == 0) { + print("Nothing to update for this batch") + return(NULL) + } else { + bulk <- apply(updates, 1, bulk_writer, varname ='actorsDetail', type = 'add', ver = ver) + bulk <- c(bulk,apply(updates[c(1,11)], 1, bulk_writer, varname='actors', type = 'add', ver = ver)) + return(elastic_update(bulk, es_super = es_super, localhost = localhost)) + } + }