# 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))
}
# give a document id
z <- docs_create(x, index = 'plos', id = 1002,
body = list(id = "12345", title = "New title"))
z
# and the document is there now
docs_get(x, index = 'plos', id = 1002)
# let Elasticsearch create the document id for you
z <- docs_create(x, index='plos', body=list(id="6789", title="Some title"))
z
# and the document is there now
docs_get(x, index='plos', id=z$`_id`)
# }
Run the code above in your browser using DataLab