Use the bulk API to create documents
Use the bulk API to create documents
docs_bulk_create( conn, x, index = NULL, type = NULL, chunk_size = 1000, doc_ids = NULL, es_ids = TRUE, raw = FALSE, quiet = FALSE, query = list(), ... )
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 |
es_ids |
(boolean) Let Elasticsearch assign document IDs as UUIDs.
These are sequential, so there is order to the IDs they assign.
If |
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 |
... |
Pass on curl options to crul::HttpClient |
For doing create with a file already prepared for the bulk API,
see docs_bulk()
Only data.frame's are supported for now.
Other bulk-functions:
docs_bulk_delete()
,
docs_bulk_index()
,
docs_bulk_prep()
,
docs_bulk_update()
,
docs_bulk()
## 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) docs_bulk_create(x, df, 'foobar', es_ids = FALSE) Search(x, "foobar", asdf = TRUE)$hits$hits # more examples docs_bulk_create(x, mtcars, index = "hello") ## field names cannot contain dots names(iris) <- gsub("\\.", "_", names(iris)) docs_bulk_create(x, iris, "iris") ## type can be missing, but index can not docs_bulk_create(x, iris, "flowers") ## big data.frame, 53K rows, load ggplot2 package first # res <- docs_bulk_create(x, diamonds, "diam") # Search(x, "diam")$hits$total$value ## End(Not run)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.