ropensci / elastic

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

'docs_bulk' & 'docs_bulk_update' failing with character ids #212

Closed AMR-KELEG closed 6 years ago

AMR-KELEG commented 6 years ago

I am currently having a problem with using character ids in bulk operations. The docs_bulk and docs_bulk_update only works with numeric ids! Am i missing something?

> df <- data.frame(name = letters[1:3], size = 1:3, id =c("AB", "CD", "EF"))
> invisible(docs_bulk(df, 'foobar', 'foobar', es_ids = FALSE))
  |==================================================================================================| 100%Error in Summary.factor(1:3, na.rm = FALSE) : 
  ‘max’ not meaningful for factors
R version 3.4.2 (2017-09-28)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 17.10

Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1

locale:
 [1] LC_CTYPE=en_US.UTF-8          LC_NUMERIC=C                  LC_TIME=ar_EG.UTF-8          
 [4] LC_COLLATE=en_US.UTF-8        LC_MONETARY=ar_EG.UTF-8       LC_MESSAGES=en_US.UTF-8      
 [7] LC_PAPER=ar_EG.UTF-8          LC_NAME=ar_EG.UTF-8           LC_ADDRESS=ar_EG.UTF-8       
[10] LC_TELEPHONE=ar_EG.UTF-8      LC_MEASUREMENT=ar_EG.UTF-8    LC_IDENTIFICATION=ar_EG.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] jsonlite_1.5       quanteda_1.0.0     elastic_0.8.2.9210 RWeka_0.4-37       fpc_2.1-11        
 [6] NbClust_3.0        cluster_2.0.6      wordcloud_2.5      RColorBrewer_1.1-2 tm_0.7-3          
[11] NLP_0.1-11        

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.15        pillar_1.1.0        DEoptimR_1.0-8      compiler_3.4.2      plyr_1.8.4         
 [6] stopwords_0.9.0     class_7.3-14        tools_3.4.2         prabclus_2.2-6      RWekajars_3.9.2-1  
[11] mclust_5.4          lubridate_1.7.2     tibble_1.4.2        gtable_0.2.0        lattice_0.20-35    
[16] rlang_0.1.6         fastmatch_1.1-0     Matrix_1.2-11       ggrepel_0.7.0       curl_3.1           
[21] yaml_2.1.16         parallel_3.4.2      mvtnorm_1.0-7       rJava_0.9-9         stringr_1.2.0      
[26] trimcluster_0.1-2   httr_1.3.1          xml2_1.2.0          stats4_3.4.2        diptest_0.75-7     
[31] grid_3.4.2          nnet_7.3-12         robustbase_0.92-8   data.table_1.10.4-3 R6_2.2.2           
[36] flexmix_2.3-14      spacyr_0.9.3        magrittr_1.5        kernlab_0.9-25      ggplot2_2.2.1      
[41] scales_0.5.0        modeltools_0.2-21   MASS_7.3-47         colorspace_1.3-2    stringi_1.1.6      
[46] network_1.13.0      RcppParallel_4.3.20 lazyeval_0.2.1      munsell_0.4.3       slam_0.1-42  
sckott commented 6 years ago

thanks @AMR-KELEG - i'm guessing that a data.frame with ids as factors doesn't work, will have a look

sckott commented 6 years ago

@AMR-KELEG Please try again after reinstalling devtools::install_github("ropensci/elastic")

AMR-KELEG commented 6 years ago

@sckott Thanks alot! I tried to understand and solve the problem but i am not that familiar with R :sweat_smile:

sckott commented 6 years ago

np. i avoid factors in data.frames so i didn't' run into this problem, i should have thought about that :(