# NOT RUN {
# connection setup
(x <- connect())
if (!index_exists(x, "plos")) {
plosdat <- system.file("examples", "plos_data.json", package = "elastic")
invisible(docs_bulk(x, plosdat))
}
if (!index_exists(x, "shakespeare")) {
shake <- system.file("examples", "shakespeare_data_.json", package = "elastic")
invisible(docs_bulk(x, shake))
}
# Create/update an alias
alias_create(x, index = "plos", alias = "candles")
## more than one alias
alias_create(x, index = "plos", alias = c("tables", "chairs"))
# associate an alias with two multiple different indices
alias_create(x, index = c("plos", "shakespeare"), alias = "stools")
# Retrieve a specified alias
alias_get(x, index="plos")
alias_get(x, alias="tables")
alias_get(x, alias="stools")
aliases_get(x)
# rename an alias
aliases_get(x, "plos")
alias_rename(x, index = 'plos', alias = "stools", alias_new = "plates")
aliases_get(x, "plos")
# filtered aliases
alias_create(x, index = "plos", alias = "candles",
filter = list(wildcard = list(title = "cell")))
## a search with the alias should give titles with cell in them
(titles <- Search(x, "candles", asdf = TRUE)$hits$hits$`_source.title`)
grepl("cell", titles, ignore.case = TRUE)
# routing
alias_create(x, index = "plos", alias = "candles",
routing = "1")
# Check for alias existence
alias_exists(x, index = "plos")
alias_exists(x, alias = "tables")
alias_exists(x, alias = "adsfasdf")
# Delete an alias
alias_delete(x, index = "plos", alias = "tables")
alias_exists(x, alias = "tables")
# Curl options
alias_create(x, index = "plos", alias = "tables")
aliases_get(x, alias = "tables", verbose = TRUE)
# }
Run the code above in your browser using DataLab