Reputation: 8301
I have the following query and I want to avoid repetions of the paths(simetric too).
MATCH (a:PERSON)-[:LIKES]->(b:PERSON)-[:LIKES]->(a) return a,b
I have try DISTINCT
keyword but I get and syntax error.
Im looking for something like (but fails too):
MATCH path=(a:PERSON)-[:LIKES]->(b:PERSON)-[:LIKES]->(a)
where DISTINCT(path)
return a,b
Upvotes: 1
Views: 84
Reputation: 11216
You could just add a simple test to make sure that one is greater than the other that way you won't receive the same pairing more than once.
MATCH (a:PERSON)-[:LIKES]->(b:PERSON)-[:LIKES]->(a)
where id(b) > id(a)
return a,b
Upvotes: 1