【发布时间】:2016-10-28 16:59:53
【问题描述】:
我使用 Neo4j Transactional Cypher HTTP 端点。
http://neo4j.com/docs/developer-manual/3.0/http-api/#rest-api-execute-multiple-statements
我需要使用多个语句进行请求,其中所有语句的密码查询相同,但参数不同:
{
"statements" : [ {
"statement" : "MATCH path=shortestPath(
(p:Person {idp:123})-[*..10]-(p2:Person {idp:{idp2}}) )
RETURN reduce(x={
last_idp: +head(nodes(path)).idp,
str:"" +head(nodes(path)).idp },
r IN relationships(path) |
{
last_idp: CASE WHEN x.last_idp = startnode(r).idp THEN endnode(r).idp ELSE startnode(r).idp END,
str: CASE WHEN x.last_idp = startnode(r).idp
THEN x.str +"-" +type(r)+"->"+ endnode(r).idp
ELSE x.str +"<-"+type(r)+"-" + startnode(r).idp
END
}
).str AS rpath",
"parameters" : {"idp2": 1234}
}, {
"statement" : "<the same chypher query as above>",
"parameters" : {"idp2": 1234}
}, {
"statement" : "<the same chypher query as above>",
"parameters" : {"idp2": 1235}
},
...
{
"statement" : "<the same chypher query as above>",
"parameters" : {"idp2": 1255}
} ]
}
如何简化请求以避免重复密码查询字符串?
而且我想避免解析和规划相同查询的不必要成本。 有可能吗?
【问题讨论】:
-
如果是完全相同的查询,则不会再次解析或计划:Cypher 引擎会缓存这些。
标签: rest neo4j parameter-passing cypher