Запрос sMy Cypher находит общие дочерние узлы для нескольких начальных узлов. Для каждого пути извлекается и возвращается только его идентификатор узла, в результате чего в каждом пути появляются сотни строк. См. Пример p1 и p2 (показаны только 3 ряда и две начальные точки).
Match p1=(n1:node{name:"x" })-[r:sub*]->(i)), p2=(n2:node{name:"y" })-[r:sub*]->(i))
RETURN DISTINCT i, extract(a IN nodes(p1)| a.id) as p1, extract(b IN nodes(p2)| b.id) as p2
----RESULTS----
p1=1,4,3
p1=1,8,3
p1=1,8,9,3
p2=6,7,3
p2=6,5,9,3
p2=6,7,10,3
Я бы хотел пересечь пути в cypher во время запроса, чтобы мне не приходилось делать это после. В php я бы повторил, используя:
$result = array_intersect($p1,$p2);
Это вернет 9,3 из приведенного выше примера, потому что это единственные общие узлы, общие для всех путей. Есть ли способ сделать это в Cypher, чтобы мне не возвращались сотни строк?
Спасибо!