Reputation: 687
Don't have much experience in Cypher
paths queries, but it seems that paths are the rational way to do what I want efficiently...
I have the following relevant relationships in my Neo4j
:
p1-[r:SNEAK]->otherProfile
p1-[r:FRIEND]-otherProfile (the direction not relevant)
p1-[r:HANG]->venue<-[r:HANG]-otherProfile
p1-[r:INTERACT]->session<-[r:INTERACT]-otherProfile
p1-[r:INTERACT]->session<-[r:LIKE]-otherProfile
Let's say I have p1 in my hand, I want to perform a query to retrieve all the profiles where at least one condition from the following is exist (with distinct on the profiles):
I also need the ability to extract the relation types in order to figure out what is the relation between these profiles...
At first it seems simple just retrieve all the below paths:
p=p1-[r*1..2]-profile
Few problems with that :
1) It will returns also profiles which sneaked at p1
2) It will returns also profiles which one of p1 friends sneaked at them
3) It will returns also profiles which are friends of profiles p1 sneaked on them
Is it possible to perform one Cypher
query which will do the job for my use-case?
Upvotes: 2
Views: 213
Reputation: 7501
An Easy shortcut is the ability to do path qualifiers in the WHERE
clause using not. So you can do your match, and then specify WHERE NOT(p1-[:SNEAK*1..2]->profile)
or however you want to qualify it.
Upvotes: 2