I’m trying to connect R to an reporting server in our network by using the elastic package, but for some reason it won’t connect.
If I logon remotely to the server, and use R with elastic, I can do connect() and R can read/write to the elastic db.
When I’m on my desktop and try to connect by using: connect(es_base==“http://192.168.x.x”, es_port=“5601”)
I get:
Error: lexical error: invalid char in json text.
var hashRoute = '/app/k
When using port 9200 I get:
Error:
Failed to connect to http://vm-reporting.kela.be:9200
Remember to start Elasticsearch before connecting
I was using 0.6.0, now I did an upgrade to the newest R-project, and elastic 0.8 and the problem is solved.
The problem was on connect()
We are in domain with different PC’s and servers, desktop was referring to my PC, in the same domain as the server, I could ping directly with no problem, but connect() wasn’t possible.
Whoops, I think I was a bit too optimistic.
Connect worked out, but when I do a search, I get the same error.
Situation so far:
I 'm in a client-server environment, and trying to connect from R on my laptop to the elastic server, all in the same domain.
code:
connect(es_host=“reportingsrv”, es_port = 5601)
res <- Search(“ES-sales”, q=‘status:“B” AND doctype:“order”’,
body = ‘{
"_source": ["_id", “posnr”,“order quantity”, “open order quantity”]
}’,
size=10000)
After running this code I get:
Error: lexical error: invalid char in json text.
var hashRoute = '/app/k
(right here) ------^
I tried both suggestions, but still the error message is only:
Error: lexical error: invalid char in json text.
var hashRoute = '/app/k
(right here) ------^
Running the same Search directly on our reporting server gives no errors.
Can you do the request on the command line with curl or similar tool? Curious if that works. The error invalid char in json text. sure seems like it’s not getting back JSON or not getting back valid JSON for some reason
hmm, it seems like something to do with your configuration/setup. Maybe you have to be on the server and not connecting from another computer/IP address? Or a certain user-agent string?