Description Usage Arguments References See Also Examples
View source: R/docs_delete_by_query.R
delete documents by query via a POST request
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
conn |
an Elasticsearch connection object, see |
index |
(character) The name of the index. Required |
body |
(character/json) query to be passed on to POST request body |
type |
(character) The type of the document. optional |
conflicts |
(character) If you’d like to count version conflicts
rather than cause them to abort then set |
routing |
(character) Specific routing value |
scroll_size |
(integer) By default uses scroll batches of 1000. Change batch size with this parameter. |
refresh |
(logical) Refresh the index after performing the operation |
wait_for_completion |
(logical) If |
wait_for_active_shards |
(logical) controls how many copies of a shard must be active before proceeding with the request. |
timeout |
(character) Explicit operation timeout, e.g,. 5m (for 5 minutes) |
scroll |
(integer) control how long the "search context" is kept
alive, eg |
requests_per_second |
(integer) any positive decimal number
(1.4, 6, 1000, etc); throttles rate at which |
... |
Curl args passed on to crul::verb-POST |
https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | ## Not run:
(x <- connect())
x$ping()
plosdat <- system.file("examples", "plos_data.json",
package = "elastic")
plosdat <- type_remover(plosdat)
if (!index_exists(x, "plos")) invisible(docs_bulk(x, plosdat))
# delete with fuzzy matching
body <- '{
"query": {
"match": {
"title": {
"query": "cells",
"fuzziness": 1
}
}
}
}'
docs_delete_by_query(x, index='plos', body = body)
# delete with no fuzziness
if (index_exists(x, "plos")) index_delete(x, 'plos')
invisible(docs_bulk(x, plosdat))
count(x, "plos")
body <- '{
"query": {
"match": {
"title": {
"query": "cells",
"fuzziness": 0
}
}
}
}'
docs_delete_by_query(x, index='plos', body = body)
# delete all docs with match_all query
if (index_exists(x, "plos")) index_delete(x, 'plos')
invisible(docs_bulk(x, plosdat))
body <- '{
"query": {
"match_all": {}
}
}'
docs_delete_by_query(x, index='plos', body = body)
# put plos back in
if (index_exists(x, "plos")) index_delete(x, 'plos')
invisible(docs_bulk(x, plosdat))
# delete docs from more than one index
foo <- system.file("examples/foo.json", package = "elastic")
if (!index_exists(x, "foo")) invisible(docs_bulk(x, foo))
bar <- system.file("examples/bar.json", package = "elastic")
if (!index_exists(x, "bar")) invisible(docs_bulk(x, bar))
body <- '{
"query": {
"match_all": {}
}
}'
docs_delete_by_query(x, index=c('foo','bar'),
body = body, verbose = TRUE)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.