raj
raj

Reputation: 127

cypher with multiple relationships filter

I have the following query

MATCH (wallstreet { title:'Wall Street' })<-[r:ACTED_IN|DIRECTED]-(person)
RETURN person

I need to

  1. apply a filter on ACTED_IN and DIRECTED separately.

  2. a path could contain ACTED_IN twice. I may need to apply two conditions with OR or AND.

  3. apply INCOMING and OUTGOING and BOTH separately for ACTED_IN and DIRECTED

Can any body provide the cypher query that satisfies the above three requirements?

Pseudo cypher

MATCH (wallstreet { title:'Wall Street' })<-[r:ACTED_IN{Name:"Titanic"}|r1:DIRECTED{Name:"iceage1"}|r1:DIRECTED{Name:"Iceage2"}]-(person)
RETURN person

IF you observe the Psedo code , I have changed only relationship part .I added Three relationships in which TWO are of same type.I added filter properties for each relationships in relationship part.

Upvotes: 1

Views: 1929

Answers (1)

cybersam
cybersam

Reputation: 67044

This might be close to what you are looking for. I assume that movie titles are stored in movie nodes, not in relationships:

MATCH ({title:'Wall Street'})<-[:ACTED_IN|DIRECTED]-(person)-[r:ACTED_IN|DIRECTED]->(other)
WHERE
  (TYPE(r) = 'ACTED_IN' AND other.title = 'Titanic') OR
  (TYPE(r) = 'DIRECTED' AND other.title IN ['Ice Age 1', 'Ice Age 2'])
RETURN person;

The query finds all people who acted in or directed "Wall Street" who also acted in "Titanic" or directed either of the first 2 "Ice Age" movies.

Upvotes: 2

Related Questions