I'm trying to send queries from my R session to neo4j
Looking at the REST API docs provided by neo4j: http://docs.neo4j.org/chunked/milestone/rest-api-cypher.html I've formulated a successful curl query below
curl -X POST -d @test.json http://localhost:7474/db/data/cypher -H "Content-Type: application/json"
where the contents of test.json are as follows
{"query": "start pathway=node:pathwayid(pathway={pathway}) match pathway--(ko:`ko`)<-[r]-(cpd:`cpd`) return ko.ko,r,cpd.cpd limit 5;","params": {"pathway":"path:ko00010"} }
Solutions given so far on SO in Use neo4j with R where the query is stored in querystring (see code below) do not utilise ability to parameterise the cypher query. eg:
library(RCurl)
library(RJSONIO)
h = basicTextGatherer()
curlPerform(url="localhost:7474/db/data/ext/CypherPlugin/graphdb/execute_query",
postfields=paste('query',curlEscape(querystring), sep='='),
writefunction = h$update,
verbose = FALSE
)
result <- fromJSON(h$value())
in this case querystring is:
start pathway=node:pathwayid('pathway:"path:ko00010"') match pathway--(ko:`ko`)<-[r]-(cpd:`cpd`) return ko.ko,r,cpd.cpd limit 5;
I'm curious how do i parse parameters into the RCurl.
postfields=paste('query',curlEscape(querystring), sep='=')
– altimit