docs_update_by_query {elastic} | R Documentation |
Update documents by query
Description
update documents by query via a POST request
Usage
docs_update_by_query(
conn,
index,
body = NULL,
type = NULL,
conflicts = NULL,
routing = NULL,
scroll_size = NULL,
refresh = NULL,
wait_for_completion = NULL,
wait_for_active_shards = NULL,
timeout = NULL,
scroll = NULL,
requests_per_second = NULL,
pipeline = NULL,
...
)
Arguments
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 |
pipeline |
(character) a pipeline name |
... |
Curl args passed on to crul::verb-POST |
References
https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update-by-query.html https://www.elastic.co/guide/en/elasticsearch/painless/current/painless-api-reference.html
See Also
Examples
## Not run:
(x <- connect())
x$ping()
omdb <- system.file("examples", "omdb.json", package = "elastic")
omdb <- type_remover(omdb)
if (!index_exists(x, "omdb")) invisible(docs_bulk(x, omdb))
# can be sent without a body
docs_update_by_query(x, index='omdb')
# update
## note this works with imdbRating, a float, but didn't seem to work
## with Metascore, a long
## See link above for Painless API reference
body <- '{
"script": {
"source": "ctx._source.imdbRating++",
"lang": "painless"
},
"query": {
"match": {
"Rated": "R"
}
}
}'
Search(x, "omdb", q = "Rated:\"R\"", asdf=TRUE,
source = c("Title", "Rated", "imdbRating"))$hits$hits
docs_update_by_query(x, index='omdb', body = body)
Search(x, "omdb", q = "Rated:\"R\"", asdf=TRUE,
source = c("Title", "Rated", "imdbRating"))$hits$hits
## End(Not run)