ropensci / elastic

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

docs_bulk_update giving not_x_content_exception #260

Closed ktang98 closed 4 years ago

ktang98 commented 4 years ago
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', 'foobar', es_ids = FALSE))
(df2 <- data.frame(size = c(45, 56), id = 100:101))
Search(x, "foobar", asdf = TRUE)$hits$hits
invisible(docs_bulk_update(x, df2, index = 'foobar', type = 'foobar'))

Hi I'm trying to use the doc_bulk_update function. The code I pasted is directly from the elastic 1.0.0 documentation. When I run the docs_bulk_update line (without the invisible), I get a "not_x_content_exception error: compressor detection can only be called on some xcontent bytes or compressed xcontent bytes".

What's curious is that in trying to fix the issue, it seems that as long as I try to update more than 1 field (other than 'id') at a time, the function works. For example, the following code runs successfully:

(df2 <- data.frame(size2 = c(45, 56), word ="hi"))
invisible(docs_bulk_update(x, df2, index = 'foobar', type = 'foobar', doc_ids = c(100,101), raw=TRUE))

Please let me know if I am thinking about or using this function incorrectly. Thanks!

Session Info ```r R version 3.6.0 (2019-04-26) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows Server 2012 R2 x64 (build 9600) Matrix products: default locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] rjson_0.2.20 stringr_1.4.0 microbenchmark_1.4-6 re2r_0.2.0 readr_1.3.1 [6] stringi_1.4.3 XML_3.98-1.20 RCurl_1.95-4.12 bitops_1.0-6 digest_0.6.19 [11] wordcloud_2.6 RColorBrewer_1.1-2 shinyBS_0.61 shinycssloaders_0.2.0 shinyWidgets_0.4.8 [16] lubridate_1.7.4 plotly_4.9.0 ggplot2_3.2.0 jsonlite_1.6 elastic_1.0.0 [21] fst_0.9.0 DT_0.7 data.table_1.12.2 shiny_1.3.2 loaded via a namespace (and not attached): [1] tidyselect_0.2.5 purrr_0.3.2 colorspace_1.4-1 sourcetools_0.1.7 htmltools_0.3.6 viridisLite_0.3.0 [7] yaml_2.2.0 rlang_0.3.4 later_0.8.0 pillar_1.4.1 httpcode_0.2.0 glue_1.3.1 [13] withr_2.1.2 munsell_0.5.0 gtable_0.3.0 htmlwidgets_1.3 httpuv_1.5.1 crosstalk_1.0.0 [19] parallel_3.6.0 curl_3.3 urltools_1.7.3 triebeard_0.3.0 Rcpp_1.0.1 xtable_1.8-4 [25] promises_1.0.1 scales_1.0.0 RcppParallel_4.4.3 mime_0.6 hms_0.4.2 dplyr_0.8.1 [31] grid_3.6.0 tools_3.6.0 magrittr_1.5 lazyeval_0.2.2 tibble_2.1.2 crul_0.7.4 [37] crayon_1.3.4 tidyr_0.8.3 pkgconfig_2.0.2 assertthat_0.2.1 httr_1.4.0 R6_2.4.0 [43] compiler_3.6.0 ```
sckott commented 4 years ago

thanks for your report.

i'll have a look

sckott commented 4 years ago

document creation for bulk update is not working correctly when there's only 1 field being updated.

just pushed. a fix, reinstall and try again