# NOT RUN {
(x <- connect())
x$ping()
if (!index_exists(x, "plos")) {
plosdat <- system.file("examples", "plos_data.json",
package = "elastic")
plosdat <- type_remover(plosdat)
docs_bulk(x, plosdat)
}
# delete a document
if (!docs_get(x, index='plos', id=36, exists=TRUE)) {
docs_create(x, index='plos', id=36,
body = list(id="12345", title="New title")
)
}
docs_get(x, index='plos', id=36)
docs_delete(x, index='plos', id=36)
# docs_get(x, index='plos', id=36) # and the document is gone
# }
Run the code above in your browser using DataLab