ropensci / elastic

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

Rscript error 400 #206

Closed dmendez23 closed 6 years ago

dmendez23 commented 6 years ago

I have a R script (script.R) that loads 25-30K documents in elasticsearch in each execution.

The point is that I can execute it in Rstudio properly. However, when I try to execute it from command line using Rscript I always get the same error:

Error: 400 - failed to parse In addition: There were 50 or more warnings (use warnings() to see the first 50) Execution halted

The strangest thing is that when this error occurs there are loaded different amount of documents in elastic (sometimes 1.5K, sometimes 3K, etc...). So it seems that it doesn't occurs always at same time.

I am totally sure that I get the 400 error executing the elastic docs_create function.

This is the Rscript execution:

/usr/bin/Rscript /Rdir/script.R

sckott commented 6 years ago

thanks @dmendez23

For large amount of documents, the bulk API https://www.elastic.co/guide/en/elasticsearch/reference/6.0/docs-bulk.html seems more appropriate. Have you seen elastic::docs_bulk function?

There could be lots of different problems, hard to know without seeing your file. one potential thing is are you forgetting to set the connection to your elasticsearch instance?

dmendez23 commented 6 years ago

Thanks @sckott I have proved the elastic::docs_bulk function and it seems to work! I leaved the script executing last days and I haven't done the same problems anymore.

Thanks for the help!

sckott commented 6 years ago

great, glad its working