# NOT RUN {
(x <- connect())
if (!index_exists(x, 'plos')) {
plosdat <- system.file("examples", "plos_data.json",
package = "elastic")
plosdat <- type_remover(plosdat)
invisible(docs_bulk(x, plosdat))
}
docs_create(x, index='plos', id=1002,
body=list(id="12345", title="New title"))
# and the document is there now
docs_get(x, index='plos', id=1002)
# update the document
docs_update(x, index='plos', id=1002,
body = list(doc = list(title = "Even newer title again")))
# get it again, notice changes
docs_get(x, index='plos', id=1002)
if (!index_exists(x, 'stuffthings')) {
index_create(x, "stuffthings")
}
docs_create(x, index='stuffthings', id=1,
body=list(name = "foo", what = "bar"))
docs_update(x, index='stuffthings', id=1,
body = list(doc = list(name = "hello", what = "bar")),
source = 'name')
# }
Run the code above in your browser using DataLab