Neo4j - Cypher节点和关系关系

Neo4j - Cypher node and relationship relation

我有以下查询:

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)

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

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

...
WITH DISTINCT rel, childD, dg 
MATCH (childD)-[tmp]-() WHERE tmp = rel
RETURN rel, child, dg

或者直接比较:

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