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