【发布时间】:2014-01-14 11:16:38
【问题描述】:
我正在尝试从我的 R 会话向 neo4j 发送查询
查看 neo4j 提供的 REST API 文档:http://docs.neo4j.org/chunked/milestone/rest-api-cypher.html 我在下面制定了一个成功的 curl 查询
curl -X POST -d @test.json http://localhost:7474/db/data/cypher -H "Content-Type: application/json"
其中test.json的内容如下
{"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"} }
到目前为止在Use neo4j with R 中给出的解决方案 查询存储在查询字符串中(参见下面的代码),不利用参数化密码查询的能力。例如:
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())
在这种情况下查询字符串是:
start pathway=node:pathwayid('pathway:"path:ko00010"') match pathway--(ko:`ko`)<-[r]-(cpd:`cpd`) return ko.ko,r,cpd.cpd limit 5;
我很好奇如何将参数解析到 RCurl。
【问题讨论】:
-
我猜我将不得不更改这部分 r 代码
postfields=paste('query',curlEscape(querystring), sep='=')