新手问题...我正在尝试与Cypher建立多种关系。我发现了example in the documentation 几乎是我想要的:
MATCH (wallstreet { title: 'Wall Street' })<-[:ACTED_IN|:DIRECTED]-(person)
RETURN person.name
就我而言,关系往相反的方向发展。
CREATE
(a:Entity { name: 'Entity A'),
(b:Person { name: 'Person B'),
(c: Entity { name: 'Entity C'),
(c)-[:ALIAS_OF]->(b),
(b)-[:MEMBER_OF]->(a)
我想找到Person B所属的每个实体,或者是ALIAS_OF Person B,然后找到由这些实体中的任何一个实体生产的产品
MATCH (b:Person { name: 'Person B'}),
(entities:Entity)<-[:ALIAS_OF|MEMBER_OF]-(b),
(products:Product)-[:PRODUCED_BY]->(entities)
RETURN b, entities, products
当别名关系朝另一个方向移动时,这只会找到b是成员的实体。如何适应呢?是否表明我应该以相同的方式构建关系?谢谢!
答案 0 :(得分:1)
如果您不在乎关系的方向,则箭头 头可以省略...
https://neo4j.com/docs/developer-manual/current/cypher/syntax/patterns/#cypher-pattern-relationship
develop