0
我有一個初學者Cypher的問題。我有這樣一個查詢:Cypher:從查詢中返回節點和邊?
MATCH (rebecca:Person {name:"Rebecca"})-[1..2]->(companies:Company)
RETURN companies
這將返回麗貝卡的兩跳內的所有公司,但它只返回最終公司的節點。我怎樣才能看到邊緣和中間節點呢?
我有一個初學者Cypher的問題。我有這樣一個查詢:Cypher:從查詢中返回節點和邊?
MATCH (rebecca:Person {name:"Rebecca"})-[1..2]->(companies:Company)
RETURN companies
這將返回麗貝卡的兩跳內的所有公司,但它只返回最終公司的節點。我怎樣才能看到邊緣和中間節點呢?
您只能返回別名的實體。
MATCH (rebecca:Person {name:"Rebecca"})-[1..2]->(companies:Company)
RETURN companies
添加r
別名你的人際關係:
MATCH (rebecca:Person {name:"Rebecca"})-[r*1..2]->(companies:Company)
RETURN companies, r
回訪中間節點,你可以把它的路徑:
MATCH p=(rebecca:Person {name:"Rebecca"})-[r*1..2]->(companies:Company)
RETURN companies, relationships(p), nodes(p)
您也可以返回公司與沿(relationship,startnode,endnode)的地圖:
MATCH (rebecca:Person {name:"Rebecca"})-[r*1..2]->(companies:Company)
RETURN companies,
extract(x IN r | {rel: x, start: startNode(x), end: endNode(x)})
很好的答案,謝謝! – Richard