Last chance! 50% off unlimited learning
Sale ends in
Delete a document
docs_delete(
conn,
index,
id,
type = NULL,
refresh = NULL,
routing = NULL,
timeout = NULL,
version = NULL,
version_type = NULL,
callopts = list(),
...
)
an Elasticsearch connection object, see connect()
(character) The name of the index. Required
(numeric/character) The document ID. Can be numeric or character. Required
(character) The type of the document. optional
(logical) Refresh the index after performing the operation
(character) Specific routing value
(character) Explicit operation timeout, e.g,. 5m (for 5 minutes)
(character) Explicit version number for concurrency control
(character) Specific version type. One of internal or external
Curl args passed on to crul::HttpClient
Further args to query DSL
https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete.html
# 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