mingzhao.pro
mingzhao.pro

Reputation: 759

NEO4J: find a node according to multiple relationships

I hope to find a node according to multiple relationship to other nodes. For example, find a movie acted by actor A, directed by B and filmed by C.

Can anyone tell me how to do that?

Perhaps START would do that but since it needs legacy index, I prefer match.

Upvotes: 1

Views: 363

Answers (1)

David Makogon
David Makogon

Reputation: 71028

You should be able to string multiple matches together, such as:

MATCH (m:Movie)<-[:ACTED_IN]-(a:Actor),
      (m:Movie)<-[:DIRECTED]-(d:Director),
      (m:Movie)<-[:FILMED_BY]-(f:Filmer)

or:

MATCH (m:Movie)<-[:ACTED_IN]-(a:Actor)
MATCH (m:Movie)<-[:DIRECTED]-(d:Director)
MATCH (m:Movie)<-[:FILMED_BY]-(f:Filmer)

Note: I haven't tested this, but I believe both styles should work. And... for brevity, I left out details such as specifying actor/director/filmer name, and the RETURN portion. (and I made an assumption you were using labels; again, just an example on how to accomplish this).

Upvotes: 2

Related Questions