Jack Daniel
Jack Daniel

Reputation: 2611

Neo4j - Two conditions in a relationship

I want to retrieve paths between the nodes with two conditions on relationship.

1)Retrieve nodes upto two levels
    Ex: Path between "A" and "B"
    So, path can be anything like A-->B (or) A-->x-->B (or) A-->x-->y-->B

2)Property in the relationship should hold some specific value
    Ex: Property in the relationship is Val:Decimal Value
    So, relationship.val >= 0.5

Here is my initial query,

 MATCH p=(a:amps{word:"review"})-[r*1..2]->(b:amps)  
 RETURN p 

Now, How can I add another condition to the relationship. The second relationship condition specified into the above query.

Upvotes: 2

Views: 541

Answers (1)

Brian Underwood
Brian Underwood

Reputation: 10856

No problem!

MATCH p=(a:amps{word:"review"})-[r*1..2]->(b:amps)  
WHERE ALL(rel IN rels(p) WHERE rel.val >= 0.5)
RETURN p

Upvotes: 2

Related Questions