#' Generate a line-delimited JSON string for use in Elasticsearch bulk updates
#' Generate a line-delimited JSON string for use in Elasticsearch bulk updates
#'
#'
#' Generate a line-delimited JSON string for use in Elasticsearch bulk updates
#' Generate a line-delimited JSON string for use in Elasticsearch bulk updates
#' Type can be either one of three values:
#' set: set the value of [varname] to x
#' add: add x to the values of [varname]
#' @param x A single-row data frame, or a string containing the variables and/or values that should be updated (a data frame is converted to a JSON object, strings are stored as-is)
#' @param x A single-row data frame, or a string containing the variables and/or values that should be updated (a data frame is converted to a JSON object, strings are stored as-is)
#' @param index The name of the Elasticsearch index to update
#' @param index The name of the Elasticsearch index to update
#' @param varname String indicating the parent variable that should be updated (when it does not exist, it will be created)
#' @param varname String indicating the parent variable that should be updated (when it does not exist, it will be created, all varnames arexed by computerCodes)
#' @param type Type of updating to be done, can be either 'set', 'add', or 'addnested'
#' @return A string usable as Elasticsearch bulk update command, in line-delimited JSON
#' @return A string usable as Elasticsearch bulk update command, in line-delimited JSON
#' Classifier function for use in combination with the elasticizer function as 'update' parameter (without brackets), see elasticizer documentation for more information
#' Classifier function for use in combination with the elasticizer function as 'update' parameter (without brackets), see elasticizer documentation for more information
#' @param out Does not need to be defined explicitly! (is already parsed in the elasticizer function)
#' @param out Does not need to be defined explicitly! (is already parsed in the elasticizer function)
#' @param localhost Defaults to false. When true, connect to a local Elasticsearch instance on the default port (9200)
#' @param model_final The classification model (e.g. output from textstat_nb(), svm() or others)
#' @param model_final The classification model (e.g. output from textstat_nb(), svm() or others)
#' @param dfm_words A dfm containing all the words and only the words used to generate the model (is used for subsetting)
#' @param dfm_words A dfm containing all the words and only the words used to generate the model (is used for subsetting)
#' @param varname String containing the variable name to use for the classification result, usually has the format computerCodes.varname
#' @param varname String containing the variable name to use for the classification result, usually has the format computerCodes.varname
@ -9,24 +10,22 @@
#' @return As this is a nested function used within elasticizer, there is no return output
#' @return As this is a nested function used within elasticizer, there is no return output
\title{Generate a line-delimited JSON string for use in Elasticsearch bulk updates}
\title{Generate a line-delimited JSON string for use in Elasticsearch bulk updates}
\usage{
\usage{
bulk_writer(x, index = "maml", varname = "updated_variable")
bulk_writer(x, index = "maml", varname = "updated_variable", type)
}
}
\arguments{
\arguments{
\item{x}{A single-row data frame, or a string containing the variables and/or values that should be updated (a data frame is converted to a JSON object, strings are stored as-is)}
\item{x}{A single-row data frame, or a string containing the variables and/or values that should be updated (a data frame is converted to a JSON object, strings are stored as-is)}
\item{index}{The name of the Elasticsearch index to update}
\item{index}{The name of the Elasticsearch index to update}
\item{varname}{String indicating the parent variable that should be updated (when it does not exist, it will be created)}
\item{varname}{String indicating the parent variable that should be updated (when it does not exist, it will be created, all varnames arexed by computerCodes)}
\item{type}{Type of updating to be done, can be either 'set', 'add', or 'addnested'}
}
}
\value{
\value{
A string usable as Elasticsearch bulk update command, in line-delimited JSON
A string usable as Elasticsearch bulk update command, in line-delimited JSON
}
}
\description{
\description{
Generate a line-delimited JSON string for use in Elasticsearch bulk updates
Generate a line-delimited JSON string for use in Elasticsearch bulk updates
Type can be either one of three values:
set: set the value of [varname] to x
add: add x to the values of [varname]
}
}
\examples{
\examples{
bulk_writer(x, index = 'maml', varname = 'updated_variable')
bulk_writer(x, index = 'maml', varname = 'updated_variable')
\title{Classifier function for use in combination with the elasticizer function as 'update' parameter (without brackets), see elasticizer documentation for more information}
\title{Classifier function for use in combination with the elasticizer function as 'update' parameter (without brackets), see elasticizer documentation for more information}
\item{out}{Does not need to be defined explicitly! (is already parsed in the elasticizer function)}
\item{out}{Does not need to be defined explicitly! (is already parsed in the elasticizer function)}
\item{localhost}{Defaults to false. When true, connect to a local Elasticsearch instance on the default port (9200)}
\item{model_final}{The classification model (e.g. output from textstat_nb(), svm() or others)}
\item{model_final}{The classification model (e.g. output from textstat_nb(), svm() or others)}
\item{dfm_words}{A dfm containing all the words and only the words used to generate the model (is used for subsetting)}
\item{dfm_words}{A dfm containing all the words and only the words used to generate the model (is used for subsetting)}
@ -24,5 +27,5 @@ As this is a nested function used within elasticizer, there is no return output
Classifier function for use in combination with the elasticizer function as 'update' parameter (without brackets), see elasticizer documentation for more information
Classifier function for use in combination with the elasticizer function as 'update' parameter (without brackets), see elasticizer documentation for more information