Neo4j - Match by multiple relationship types

2020-06-30 04:55发布

I want to match between entities by multiple relationship types.

Is it possible to say the following query:

match (Yoav:Person{name:"Yoav"})-[:liked & watched & ... ]->(movie:Movie) return movie

I need "and" between all the relation types; Yova liked and watched and .. a movie.

标签: neo4j cypher
1条回答
做自己的国王
2楼-- · 2020-06-30 05:15

Yes, you can do something like:

match (gal:Person{name:"Yoav"})-[:liked|:watched|:other]->(movie:Movie) 
return movie

Take a look in the docs: Match on multiple relationship types

EDIT:

From the comments:

I need "and" between the relation types.. you gave me an "or"

In this case, you can do:

match (Yoav:Person{name:"Yoav"})-[:liked]->(movie:Movie),
(Yoav)-[:watched]->(movie),
(Yoav)-[:other]->(movie)
return movie
查看更多
登录 后发表回答