Neo4j - Cypher节点和关系关系

时间:2018-05-26 12:38:14

标签: neo4j cypher neo4j-apoc

我有以下查询:

MATCH (dg:DecisionGroup)-[:CONTAINS]->(childD:Decision) 
WHERE dg.id = {decisionGroupId} 
MATCH (filterCharacteristic1:Characteristic) 
WHERE filterCharacteristic1.id = 1 
WITH dg, filterCharacteristic1 
CALL apoc.index.between(childD,'HAS_VALUE_ON',filterCharacteristic1,'(value:(10))') YIELD rel 
WITH DISTINCT rel, childD, dg 
MATCH (childD)-(rel)  // here I need to go further only with 'childD' nodes that have relationship with 'rel'(match `apoc.index.between` predicate)

正如您从上面的查询中看到的那样 - 最后我尝试过滤与childD有关系的rel个节点,但我不知道如何描述它在Cypher。像(childD)-(rel)(childD)-[rel]之类的东西不起作用并导致错误。请帮忙

1 个答案:

答案 0 :(得分:1)

您需要查找匹配模式并比较关系:

...
WITH DISTINCT rel, childD, dg, startNode(rel) AS sRel, endNode(rel) AS eRel 
WHERE (childD)--(sRel) OR (childD)--(eRel)
RETURN rel, child, dg

或者你可以直接比较:

alternatingSums = a => a.reduce((accum,value,i) => (accum[i&1] += value, accum), [0,0])
相关问题