From f2312f65d5dd164bd58b4b7045ed78476fc70805 Mon Sep 17 00:00:00 2001 From: Erik de Vries Date: Thu, 25 Apr 2019 12:33:13 +0200 Subject: [PATCH] elasticizer: update to account for syntax change in newer package versions --- R/elasticizer.R | 56 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 17 deletions(-) diff --git a/R/elasticizer.R b/R/elasticizer.R index 3bb3e52..aaee087 100644 --- a/R/elasticizer.R +++ b/R/elasticizer.R @@ -22,23 +22,45 @@ elasticizer <- function(query, src = T, index = 'maml', es_pwd = .rs.askForPassw retries <- 10 ### Number of retries on error sleep <- 30 ### Number of seconds between retries httr::set_config(httr::config(http_version = 0)) - if (localhost == F) { - connect(es_port = 443, - es_transport = 'https', - es_host = 'linux01.uis.no', - es_path = 'es', - es_user = 'es', - es_pwd = es_pwd, - errors = 'complete') - } - if (localhost == T){ - connect(es_port = 9200, - es_transport = 'http', - es_host = 'localhost', - es_path = '', - es_user = '', - es_pwd = '', - errors = 'complete') + ## Transitional code for syntax change in elastic package + if (packageVersion("elastic") < 1) { + if (localhost == F) { + connect(es_port = 443, + es_transport = 'https', + es_host = 'linux01.uis.no', + es_path = 'es', + es_user = 'es', + es_pwd = es_pwd, + errors = 'complete') + } + if (localhost == T){ + connect(es_port = 9200, + es_transport = 'http', + es_host = 'localhost', + es_path = '', + es_user = '', + es_pwd = '', + errors = 'complete') + } + } else { + if (localhost == F) { + connect(port = 443, + transport = 'https', + host = 'linux01.uis.no', + path = 'es', + user = 'es', + pwd = es_pwd, + errors = 'complete') + } + if (localhost == T){ + connect(port = 9200, + transport = 'http', + host = 'localhost', + path = '', + user = '', + pwd = '', + errors = 'complete') + } } # Get all results - one approach is to use a while loop if (src == T) {