3
votes

I am trying to perform a query to retrieve all paths between two nodes a and b in which all the paths there is a relationship property fulfilled.

I have tried in many ways but I am not able to success.

MATCH p=(o{value:"a"})-[r*]-(x{value:"b"}) where has(r.property) and r.property="foo" return p

relationship part i have changed to [r*..] and many other options but not working

The function shortestpath does not help me because I want not only the shortest but all the possibilities.

Can someone help me or tell me which is the error in the query?

Thank you in advance.

2

2 Answers

9
votes

What you're looking for is the ALL predicate on the relationships collection of the path :

MATCH p=(o{value:"a"})-[r*]-(x{value:"b"})
WHERE ALL(x IN rels(p) WHERE x.property = "foo")
RETURN p

And please use labels !

0
votes

Could you add the property on the relation/edge?

()-[r:label{property:"foo"}]->()

That would force an edge with a value for foo property. I'm not a neo4j expert but interested why this would not work. Maybe you can post a mini-sample of the data for people to test it out with.