Description Usage Arguments Details References See Also Examples
View source: R/docs_bulk_update.R
Use the bulk API to update documents
1 2 3 4 5 6 7 8 9 10 11 12 13 |
conn |
an Elasticsearch connection object, see |
x |
A list, data.frame, or character path to a file. required. |
index |
(character) The index name to use. Required for data.frame input, but optional for file inputs. |
type |
(character) The type. default: |
chunk_size |
(integer) Size of each chunk. If your data.frame is smaller
thank |
doc_ids |
An optional vector (character or numeric/integer) of document ids to use. This vector has to equal the size of the documents you are passing in, and will error if not. If you pass a factor we convert to character. Default: not passed |
raw |
(logical) Get raw JSON back or not. If |
quiet |
(logical) Suppress progress bar. Default: |
query |
(list) a named list of query parameters. optional. options include: pipeline, refresh, routing, _source, _source_excludes, _source_includes, timeout, wait_for_active_shards. See the docs bulk ES page for details |
digits |
digits used by the parameter of the same name by
|
... |
Pass on curl options to crul::HttpClient |
doc_as_upsert
- is set to TRUE
for all records
For doing updates with a file already prepared for the bulk API,
see docs_bulk()
Only data.frame's are supported for now.
https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html#bulk-update
Other bulk-functions:
docs_bulk_create()
,
docs_bulk_delete()
,
docs_bulk_index()
,
docs_bulk_prep()
,
docs_bulk()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | ## Not run:
x <- connect()
if (index_exists(x, "foobar")) index_delete(x, "foobar")
df <- data.frame(name = letters[1:3], size = 1:3, id = 100:102)
invisible(docs_bulk(x, df, 'foobar', es_ids = FALSE))
# add new rows in existing fields
(df2 <- data.frame(size = c(45, 56), id = 100:101))
(df2 <- data.frame(size = c(45, 56)))
df2$`_id` <- 100:101
df2
Search(x, "foobar", asdf = TRUE)$hits$hits
invisible(docs_bulk_update(x, df2, index = 'foobar'))
Search(x, "foobar", asdf = TRUE)$hits$hits
# add new fields (and new rows by extension)
(df3 <- data.frame(color = c("blue", "red", "green"), id = 100:102))
Search(x, "foobar", asdf = TRUE)$hits$hits
invisible(docs_bulk_update(x, df3, index = 'foobar'))
Sys.sleep(2) # wait for a few sec to make sure you see changes reflected
Search(x, "foobar", asdf = TRUE)$hits$hits
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.