ropensci / elastic

R client for the Elasticsearch HTTP API
https://docs.ropensci.org/elastic
Other
245 stars 58 forks source link

Deleting multiple documents at once #237

Closed Jensxy closed 5 years ago

Jensxy commented 5 years ago

I would like to delete multiple documents from a index with a id. For example, I like to delete the documents with the ids test_6, test_7 and test_8. How do I use docs_delete to delete them all at once?

sckott commented 5 years ago

is it okay for your use case to do an lapply or for loop? e.g.,

ids <- c(1, 5, 8)
lapply(ids, function(z) docs_delete(index='plos', type='article', id=z))

there is the delete by query API, but we don't have it implemented yet https://github.com/ropensci/elastic/issues/195 - does the delete by query API do what you need?

Jensxy commented 5 years ago

Yes, I will use lapply. Thank you very much.

sckott commented 5 years ago

okay, i am going to implement the delete by query API at some point, so you can try that too when it's done

Jensxy commented 5 years ago

Okay, that would be nice because lapply takes very long. I don't know if delete by query would improve the performance.

sckott commented 5 years ago

i don't know if it would improve either, we'll see

sckott commented 5 years ago

@Jensxy this is implemented now. remotes::install_github("ropensci/elastic@r6-conn") see docs_delete_by_query()