# NOT RUN {
(x <- connect())
if (!index_exists(x, 'plos')) {
plosdat <- system.file("examples", "plos_data.json", package = "elastic")
invisible(docs_bulk(x, plosdat))
}
# give a document id
z <- docs_create(x, index='plos', type='article', id=1002,
body=list(id="12345", title="New title"))
z
# and the document is there now
docs_get(x, index='plos', type='article', id=1002)
# let Elasticsearch create the document id for you
z <- docs_create(x, index='plos', type='article',
body=list(id="6789", title="Some title"))
z
# and the document is there now
docs_get(x, index='plos', type='article', id=z$`_id`)
# }
Run the code above in your browser using DataLab