简体   繁体   English

Neo4j-密码节点和关系关系

[英]Neo4j - Cypher node and relationship relation

I have the following query: 我有以下查询:

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)

As you may see from the query above - at the end I'm trying to filter childD nodes that have the relationship with rel but I don't know how to describe it in Cypher. 从上面的查询中您可能会看到-最后,我试图过滤与rel有关系的childD节点,但我不知道如何在Cypher中对其进行描述。 Something like (childD)-(rel) or (childD)-[rel] doesn't work and leads to the error. (childD)-(rel)(childD)-[rel]不起作用并导致错误。 Please help 请帮忙

You need to look for a match pattern and compare the relationship: 您需要查找匹配模式并比较关系:

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

Or you can compare directly: 或者您可以直接比较:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM