Neo4j - узел Cypher и отношение отношения

У меня такой запрос:

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] не работает и приводит к ошибке. Пожалуйста помоги


person alexanoid    schedule 26.05.2018    source источник


Ответы (1)


Вам нужно найти образец совпадения и сравнить отношения:

...
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
person stdob--    schedule 26.05.2018