ropensci / elastic

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

Error creating documents with docs_bulk from a single column data frame #151

Closed gustavobio closed 7 years ago

gustavobio commented 7 years ago

Hello

When creating documents in bulk from a data frame, I get the following error if the data frame has only one column:

docs_bulk(specimens[1, "notes", drop = FALSE], index = "notes", type = "note")
  |======================================================================================| 100%
[[1]]
[[1]]$took
[1] 42

[[1]]$errors
[1] TRUE

[[1]]$items
[[1]]$items[[1]]
[[1]]$items[[1]]$create
[[1]]$items[[1]]$create$`_index`
[1] "notes"

[[1]]$items[[1]]$create$`_type`
[1] "note"

[[1]]$items[[1]]$create$`_id`
[1] "AVfEYIGoCNtTV-ykYzaE"

[[1]]$items[[1]]$create$status
[1] 400

[[1]]$items[[1]]$create$error
[[1]]$items[[1]]$create$error$type
[1] "mapper_parsing_exception"

[[1]]$items[[1]]$create$error$reason
[1] "failed to parse"

[[1]]$items[[1]]$create$error$caused_by
[[1]]$items[[1]]$create$error$caused_by$type
[1] "not_x_content_exception"

[[1]]$items[[1]]$create$error$caused_by$reason
[1] "Compressor detection can only be called on some xcontent bytes or compressed xcontent bytes"

If I add a second column, everything goes well:

> docs_bulk(specimens[1, c("notes", "species")], index = "notes", type = "note")
  |======================================================================================| 100%
[[1]]
[[1]]$took
[1] 18

[[1]]$errors
[1] FALSE

[[1]]$items
[[1]]$items[[1]]
[[1]]$items[[1]]$create
[[1]]$items[[1]]$create$`_index`
[1] "notes"

[[1]]$items[[1]]$create$`_type`
[1] "note"

[[1]]$items[[1]]$create$`_id`
[1] "AVfEY7bvCNtTV-ykYzaF"

[[1]]$items[[1]]$create$`_version`
[1] 1

[[1]]$items[[1]]$create$`_shards`
[[1]]$items[[1]]$create$`_shards`$total
[1] 2

[[1]]$items[[1]]$create$`_shards`$successful
[1] 1

[[1]]$items[[1]]$create$`_shards`$failed
[1] 0

[[1]]$items[[1]]$create$status
[1] 201

Thanks!

sckott commented 7 years ago

thanks for the report, i'll have a look

sckott commented 7 years ago

@gustavobio can you reinstall and try again? devtools::install_github("ropensci/elastic")

gustavobio commented 7 years ago

That was quick! Working great now, thanks!

sckott commented 7 years ago

glad it works 😼