0
votes

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.

1
I think you are going to be a little more specific if you are going to get the help you seek. Perhaps try including an example of what you think the cypher should look like - pseudo code is fine.Dave Bennett
i added the pseudo cypher in my queryraj
Are those relationship properties you specify actually properties on the relationship? I think you may have a bad data model underlying your graph. Try really hard not to use relationship properties for anything that will be used for pathfinding, it should be saved for "dumb" data storage if anything. Use more relationships and nodes if necessary to avoid the work. Path steps are cheap and easy, property reading is expensive and hard.Tore Eschliman
relationships have some properties like capacity.can anybody share the link where I can get how to design neo4j model.for example Tore has mentioned in the comment, we should not use properties in relationships.I need to know these kind of pointsraj

1 Answers

1
votes

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.