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.
The standard store format of neo4j allows for 65k different relationship types.
Neo4j cannot store bidirectional relationships. No way around this, you can however treat relationships as bidirectional when querying your graph.
The MATCH clause allows you to specify the patterns Neo4j will search for in the database. This is the primary way of getting data into the current set of bindings. It is worth reading up more on the specification of the patterns themselves in Patterns.
Relationships describes a connection between a source node and a target node. Relationships always has a direction (one direction).
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With